-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Code quality: name store exports #27226
Conversation
Size Change: +27 B (0%) Total Size: 1.2 MB
ℹ️ View Unchanged
|
I'm on the fence :) I l ike the consistency of "store" personally but I can see its drawbacks. Waiting to hear more. |
I merged 3 PRs that reference |
I have no strong preference either. I found |
I like this as well for reasons of simplicity, as having one preferred name doesn't only result in auto-importing working but also the ease in searching for other places using that particular store (although the same "searchability" is achieved with the string of the package name, this is easier). |
my preference is to keep the aliases for consistency in the modules themselves and for other approaches such as when importing all names from a module import * as editPost from '@wordpress/edit-post';
import * as viewport from '@wordpress/viewport';
doSomethignWith( editPost.store, viewport.store ); I'm frequently frustrated when working with packages that share a common concept and name but each one makes its own unique version and then I have to try and guess what it is, plus I find that these unique names tend to breakdown anyway and then we deal with the same problem of clashing import names. |
It'll be soon 2 years since this proposal 😅 We didn't take any action so it's rather impossible to change it now because of the backward compatibility concerns. Should we close this PR? |
Description
#27088 introduced a new recommended way of referencing stores:
Before
After
This is great and solves multiple issues we've had. However, I don't like the part that says
import { store as viewportStore }
. It does not play well with IDE features such as auto importing. Over time, it will likely introduce inconsistencies across the codebase - different files will refer to the same stores using different names. Why not export the preferred name and enjoy "searchability", consistency, and autocompletion? This PR does exactly that:cc @gziolo @youknowriad @ellatrix
How has this been tested?
Just confirm the units tests passed.
Types of changes
Non-breaking change
Checklist: