-
Notifications
You must be signed in to change notification settings - Fork 16
feat(select-style): add fixer #189
feat(select-style): add fixer #189
Conversation
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.
This is great, and I'm sure that it will help some codebases!
I'm going to take a look at the implementation later, but I already have a question.
e2b4fef
to
c5683f4
Compare
c5683f4
to
564c428
Compare
@@ -15,25 +15,25 @@ ruleTester().run(path.parse(__filename).name, rule, { | |||
import { Store } from '@ngrx/store' |
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.
Something that came to my mind... since we have some rules relying on Store
import, wouldn't it be a good idea to have a rule like use-consistent-global-import
or something like this? Because if I do import { Store as ngrxStore } from '@ngrx/store'
these rules won't work as expected...
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.
Looks good to me!
I'm so excited about this fix 🚀
About your question, I think it's good to keep in mind, but I also think we won't get a lot of benefit from it. Maybe we should make the store lookup mechanism smarter, so it looks for the renamed node, e.g. ngrxStore
instead of Store
?
🎉 This PR is included in version 1.30.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Oh, I just noticed that we already handle these cases properly in rules that rely on
Using The only ones that are missing are those that depend on the eslint-plugin-ngrx/src/utils/selectors/index.ts Lines 19 to 20 in dc1ff4a
But yes, I don't think it's a valid requirement to the point of having a rule just for these few cases (three rules more specifically). |
@rafaelss95 this works like a charm! For example: // before
import { select, Store } from '@ngrx/store';
this.searchQuery$ = store.pipe(select(fromBooks.selectSearchQuery));
// becomes (notice that `select` is still imported).
import { select, Store } from '@ngrx/store';
this.searchQuery$ = store.select(fromBooks.selectSearchQuery); I would've expected that the unused import also had a fixer, but it seems like it does not have one - thus after this fix we end up with a new warning 😅 |
I just sent a PR hoping to accomplish this 🙏 |
Part of #179.