-
-
Notifications
You must be signed in to change notification settings - Fork 359
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
Sort frontend imports #3552
Sort frontend imports #3552
Conversation
@seancolsen as I was not able to find any prettier plugin which supports .svelte files and I also hopped in to the svelte community to see what people have been using and it's eslint. I also found out that we are using eslint already in our repo so we can just extend it for checking (and fixing) sorting imports. We can either display warnings (without passing --fix) and allow the dev to fix the import themselves or we can give them an option to fix it using --fix. The command to sort imports for a particular file(after cloning the repo and downloading the dependencies) If you try to run this command without |
We can further modify the rules as per our requirements, but opening this PR for further discussion. Let me know if I should make it draft PR for now. |
cb81e86
to
f8a92d3
Compare
@hitenvidhani I added some changes to clean this up a bit. |
@pavish I'd like you to review this. The goal here (as described in #3542) is to set up some tooling that will keep our JS imports sorted. You've expressed some opinions about import code style. I think that with this PR we could lean on the tooling to enforce some (but not all) of those opinions. I've also notice that import statements are the most common culprit for merge conflicts. While auto-sorting would eliminate such conflicts, I think it would reduce their frequency and complexity. With this PR:
What I like about this:
What I don't like about this:
I was really hoping that we'd find a Prettier plugin that would work for Svelte. This one says Svelte support is coming soon. I spent some time researching and tinkering to see if we could wire up something with Prettier that would work, but I gave up. If you're not sold on this PR, then I could see us revisiting this topic in a year to see if there's a Prettier plugin that works with Svelte at that point. Using Prettier would be nice because it would format on save. I also tried getting ESLint to auto-fix on save but I wasn't able to set that up successfully. I could go either way with this PR. Personally I'd be inclined to merge this and see how we like the new workflow. If we end up finding it annoying we could disable it. But I have a hunch that it would add a small improvement to our DX. |
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.
@hitenvidhani @seancolsen This looks good to me!
Sean, I agree it would be a bit annoying to deal with having to run eslint regularly, and running both eslint and prettier in case of the additional line. I do think the DX would be worth it, and we can always remove this if it's not, as you mentioned.
4e619c6
Fixes #3542
Checklist
Update index.md
).develop
branch of the repositoryvisible errors.
Developer Certificate of Origin
Developer Certificate of Origin