nordic-institute/X-Road

As a Frontend Developer I want to update Pinia store naming according to the "best practices"

raits opened this issue · 0 comments

raits commented

During the Vuex to Pinia update, the new Pinia stores were named in a "non-optimal" way. It would be good to change them to match Pinia’s documentation.

Using notifications store as an example:

Current situation:

export const notifications = defineStore('notificationsStore', {

  • The function name should start with use. Without it, it looks weird when it's called in code: notification().

    "Naming the returned function use... is a convention across composables to make its usage idiomatic."

  • Id (name) of the store should not end in store. Because when used with ...mapStores Pinia automatically adds 'store' in the end. And this example would end up notificationsStoreStore.

Should be fixed like this:

export const useNotifications = defineStore('notifications', {

  • Now it looks better when called from component:   useNotifications()
  • Result of mapStore looks nicer  -> notificationsStore

Related Pinia documentation:

The JIRA ticket this issue was created from can be found here: https://nordic-institute.atlassian.net/browse/XRDDEV-1983

Acceptance criteria:

  • The naming of Pinia stores is checked and updated where needed in the Security Server
  • The naming is updated to match the conventions from the documentation
  • All automated tests pass