-
Notifications
You must be signed in to change notification settings - Fork 16
Add more fixers/suggestions #179
Comments
I would like to know what the fixer/suggestion would do 😅 Am I correct to assume that the fixer/suggestion would do the following? |
✅
✅
As it's a suggestion, I don't think we should try to change all references because that can be quite problematic as people might be using it in template, in a subclass or even in tests 🤷🏿.
I actually suggested it as a suggestion, so it would be up to developers whether or not to follow the tip 😅
Same as above for
✅
Same as |
So, if I understand correctly a suggestion could be used as: "hey, this is how it would look like - it's up to you to fix related problems"? |
Yup, that's basically my point of view on the suggestions topic. IMHO, providing suggestions can serve both as a help for the developer to resolve this report (not necessarily fixing all related issues) — see As they're manually applied, there's no risk involved as people have to see the suggestion and confirm that's what they want, different, of course, of a fixer, that could be automatically applied in multiple files at once using a script, for example. And another closer example... here in the repo, we offer suggestions for eslint-plugin-ngrx/tests/rules/prefer-inline-action-props.test.ts Lines 21 to 34 in d3a645c
It certainly breaks the places where you are using |
Thanks @rafaelss95 |
Not really related to this issue, but what would be the difference between prefixing some rules with "avoid-" and others with "no-"? I always had this curiosity 😅 |
@rafaelss95 yea, with the recently added suggestions (and your comment #179 (comment)) I kind of see it different now. I think adding the suggestion would be good 👍
I thought of |
✅
It would remove the whole const reducer = createReducer(
on(foo1, state => state),
on(foo1, ({bar}) => bar), // if you click on it, it would remove this whole line, otherwise the other(s).
)
It makes perfect sense! Thanks for clarifying :) |
I was looking at existing suggestions and was curious to see if there is any specific reason why |
@rafaelss95 that's indeed a good question! I can't remember why we did it like that, it can be converted to a fix for me 👍 |
The funny part is that it's already marked as
The same is incorrect for no-typed-global-store
Btw, the following case is currently producing compilation error: - withLatestFrom(this.store$.select(something)),
+ concatLatestFrom(this.store$.select(something)), // TS Error
+ concatLatestFrom(() => this.store$.select(something)), // This should be the correct But in general yes, I think we could offer a fixer for most cases, except for this rare case, which would be kept as a suggestion: withLatestFrom(this.store$.select(something), (one, other) => somethingElse()), Maybe a dumb question... but I see that we have this case using eslint-plugin-ngrx/tests/rules/prefer-concat-latest-from.test.ts Lines 27 to 38 in fb35ca2
Is it because it's already considered a "lazy fetch"? |
😅 I think that the suggestion doesn't break things (e.g. The projector can be replaced with a source$.pipe(withLatestFrom(this.store$.select(something)), map(([one, other]) => somethingElse())) For the "dumb" question (which isn't dumb 😉), the idea was that it was lazy so it could be left as is. |
For this lase case, perhaps we could provide an option (something like |
I like the config option 👍 |
🎉 This issue has been resolved in version 1.46.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Information about the new behavior
Thinking about a better DX, we could add fixers/suggestions for some more rules.
avoid-duplicate-actions-in-reducer
no-dispatch-in-effects
no-effect-decorator-and-creator
@Effect
contains arguments, the fixer would not be safe.)no-effects-in-providers
no-multiple-global-stores
no-reducer-in-key-names
on-function-explicit-return-type
State
as it's a common convention in reducer files)prefix-selectors-with-select
select-style
use-consistent-global-store-name
Let me know your thoughts on this, @timdeschryver :)
I would be willing to submit a PR for the docs ❤️
[x] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No
The text was updated successfully, but these errors were encountered: