Open MickL opened 4 months ago
Yes, I've been hoping for an eslint expert to show up for the last 3 years 😄. I still haven't lost hope
I've been looking into what rules would make sense for a pinia eslint plugin. Looking at the docs and came up with some ideas, what do you think @posva and @MickL?
use
followed by the store name and suffixed with Store
Sounds very good! Would it be possible to enforce that ALL variables that are defined in the store also need to be exported by the store?
Hi @MickL, here is the first version including three rules, I tried it with a vue scaffold already:
Nice, thanks a lot for the initiative @lisilinhart ! A few notes regarding the rules:
use
but maybe the Store
suffix should not be activated by default because it's okay to name it something differently like Service or other name. So I think it should be configurableref
, reactive
and other state properties. It shouldn't warn for missing functions, computed or raw data (not state)As for other other ideas:
storeToRefs()
in crossed used stores https://github.com/vuejs/pinia/discussions/2633What do you think? I think Discussions is a great place to find where people are struggling
Hey @posva, thanks for the detailed feedback. Your suggestions make a lot of sense and I'll look into adding those changes into the already existing rules in the next few days. I thought the same thing about only warning around ref
reactive
, it makes sense not to warn about more constant / helper variables or inner functions. I also need to look into more detail, which ones would be possible to autofix.
Discussions sounds like a good place to gain insight from actual use cases, should I open one and summarise the points that were mentioned here?
Feel free to open a discussion if that helps you
Hey @lisilinhart this sounds amazing! Unfortunately I am currently focusing on backend work but next week I will be back at Nuxt and try it out!
Feel free to open a discussion if that helps you
I opened the discussion here: https://github.com/vuejs/pinia/discussions/2638
What problem is this solving
Would be cool to have an Eslint plugin that provides best practices. E.g. With a setup store all variables need to be exported (according to the docs) and a plugin could warn / error if we forgot to export a variable / function.
Maybe there are more best practices or anti patterns that the plugin could warn / error about.
Proposed solution
-
Describe alternatives you've considered
No response