-
Notifications
You must be signed in to change notification settings - Fork 13
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
Setup linting and formatting with Biome #71
Setup linting and formatting with Biome #71
Conversation
I am not used to making PRs but I just noticed that the two commits of the other PR I recently made at #70 also appear in this PR, not sure if this is going to conflict or something, if it does, I’ll try to fix it from another branch. I suppose this happened because I created my |
I think this would be all it's needed, I'm marking the PR ready for review. @thejackshelton I will leave that to you, as I don't know as much of you how the plugin should behave. I am not a native English speaker, although I tried to explain myself the best I could I probably made some grammar mistakes or typos when updating the contributing guide, if you want to correct anything feel free! Finally, another subtle change this PR includes is moving the type declarations that were inside the |
One last thing, about what I said, and related to my "warning" in the contributing guide, which is:
Probably it would be best to enforce the style directly, as I said it's an option, so we can do whatever you find more convenient @thejackshelton. It can be done by adding |
WOW! Awesome job on a detailed and awesome PR so quickly @iivvaannxx! Gonna grab a bite and go over this in the next hour 😄 |
Thanks @thejackshelton! Any question or doubt you have I can answer it! |
Sweet! That's awesome.
Ah sorry you had to go through that 😓
Happy to use your best judgement here! If we do run into this case where we want to change a config option, think this is something we should open a github discussion for?
Pre-commit hook is great! So your preferred approach is it prevents you from committing along with a warning if there are any formatting errors? Some things I've noticed btw, is doing something like
|
Exactly. It will take the commits on the branch you diverged from. |
Yeah this was added recently in #69. @FloezeTv if you have insight into any drawbacks of moving it into |
Shouldn't this be in two places? Both the |
...props, | ||
children: [defaultSlot, ...Object.values(slots)], | ||
children: defaultSlot ? [defaultSlot, ...slotValues] : [...slotValues] |
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.
children: defaultSlot ? [defaultSlot, ...slotValues] : [...slotValues] | |
children: defaultSlot ? [defaultSlot, ...slotValues] : [...slotValues] |
On first glance this should work. I am hoping at some point to setup playwright tests where we can have a test suite for changes like this.
Reviewed it a couple times and happy to merge 😄 . I will create a separate commit with some small clarity changes to the contributing guide. |
I honestly don't know where such custom types should go. From what I can read on the Astro documentation, |
@thejackshelton Yeah! That would probably be the best place to discuss something like that.
Exactly, this approach allows you to identify any linter errors or formatting issues firsthand and correct them yourself. It prevents Biome from making 'changes' that you might be unfamiliar with later on. Although Biome only changes if it knows that it can be "safely" changed. Those are usually pretty trivial, but still, I prefer to do it myself. With this approach, if you have any linting or formatting error, the commit will be interrupted and the
That's just it, right now Biome is only able to parse the code between fences inside
It's funny 😂, Biome and many other linters warn you about writing that. I think it's for accessibility, but I am not sure.
It would only be needed in the The |
I am not a TypeScript expert, but as far as I know you usually write declaration files (these are Usually these are "ambient" (I think they are called) type declarations and they are global, this means TypeScript picks them up automatically without you needing to import them. Many frameworks like Next, Svelte or also Astro let users use them to extend their own types or, as @FloezeTv said, extending objects like Astro may say in the docs that you should only use them for certain things, but nothing prevents you from creating your own I just used the already existing @thejackshelton One problem of doing this is that if you try to explicitly use a type defined globally like that without importing it, Biome flags it as an error of "undeclared variable" or something like that. In this case it wasn't a problem because we weren't explicitly using the types that were defined in there, TypeScript picked them automatically, but is something to be aware of. I am not sure if it's a bug or expected behaviour, if it disrupts me in any other of my projects I'll probably file an issue to the Biome repository. |
Fixes #43 and supersedes #58.
I’ve started incorporating Biome into the repository, so far so good everything works within VSCode. Biome is able to parse all the source code, lint and format it, this includes the files with the following extensions (that I checked):
[.js, .ts, .jsx, .tsx, .astro, .json]
.I am opening this PR as a draft because I was mid-way fixing the linting errors, I am not at home and Codespaces is the biggest crap I’ve ever tried, horrible DX, constantly crashing and super slow. I will continue at home.
Note
To speed things up, I’ve used a
biome.json
config file I had in one of my other projects, so the rules may be a little opinionated to some people, I am open to discuss them if necessary.As a replacement for @siguici CI workflow to ensure the style is consistent for every contribution, I propose a
pre-commit
Git hook, which is explained in the Biome docs. I’ve used this approach and it’s pretty comfortable. The docs show how you can either “stop” a commit if it has formatting or linting errors, or how to automatically run the formatter (in case there are no more things to fix) before a commit. I prefer the former to actually acknowledge everything is right before you commit anything, but the latter is also good to me if preferred.TODO
lefthook
@thejackshelton Before merging this I would like you to review and test that everything works as expected, not that I am changing the source code very much or anything, but while fixing the linting errors some rules require to “rewrite” some parts of the code to accomodate these rules. If any unexpected issue arises we can look into it (I will try not to make it happen).
And as a final note, this PR also contains a very subtle change that shouldn’t affect anything but I noticed it while installing Biome. I fixed it because I didn’t think a single PR for it would be of any help. This is moving the
changesets
dependency fromdependencies
todevDependencies
in the rootpackage.json