Add eslint rule for preventing string literals in select/dispatch/useDispatch#28726
Conversation
|
Size Change: -12 B (0%) Total Size: 1.37 MB
ℹ️ View Unchanged
|
080ac2d to
fd5f95f
Compare
|
Let's downgrade those new rules to warning level and land immediately to simplify the process for remaining hardcoded store references. |
1f4a643 to
ca1cea1
Compare
|
Found one false report. We use import { text, select } from '@storybook/addon-knobs'; |
Yes, I see this being an issue in more places. It should match the following:
Plus something you listed related to the registry maybe, definitely less common. I don't mind we start small and expand later. It probably should always remind off in the recommended WordPress ESLint config since it's totally fine to reference a store as a string in a small plugin. We should also document this rule and add tests (which is quite simple with the rule tester). Let me know how would you like to split work so I could help you land this PR. |
I'm looking into how to make this more accurate.
If you could take care of documenting and testing that would be great! |
|
The rule seems to work! Added tests as well. |
gziolo
left a comment
There was a problem hiding this comment.
I added missing documentation and left two minor comments. In general, this PR is ready to land. It just needs to be aligned in regards to the rule name. You can pick whatever works best for you but make sure you update docs accordingly.
Thank you for working on this rule. It's going to be super helpful ❤️
|
All the issues reported by CI seem to be unrelated 🤷🏻♂️ |
Description
Follow-up for #26655.
Add warning for these function calls:
select,dispatch,useDispatch,withDispatch,withSelect,createRegistrySelector,controls.select,controls.dispatch, andcontrols.resolveSelectif the first argument is a literal.Examples that will show a warning:
How has this been tested?
npm run lint-jsselect,dispatch,useDispatch,withDispatch,withSelect,createRegistrySelector,controls.select,controls.dispatch, andcontrols.resolveSelect.Types of changes
Code quality
Checklist: