-
-
Notifications
You must be signed in to change notification settings - Fork 91
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
feat(always-return): add ignoreAssignmentVariable
option
#518
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.
PR Compliance Checks Passed!
always-return
, enable ignoreLastCallback by default
I could still be persuaded (or overruled), but I'm personally a little wary of such a change as this. I think it's safer for the default to annoy rather than accidentally avoid warnings. In the case of libraries at least, one typically does want to always return. |
I’d simply argue that, since this plugin is not eslint-plugin-n (and therefore not node specific), we should definitely take into account browser usage where these non blocking async globalThis assignments are common I think the eslint-community plugins’ recommended presets should only error for usages that are incorrect ~100% of the time For instance the chained .then usage where a .then in the middle does not return anything is most definitely not a correct usage, but for the last one we can argue cases like these, so it’d be more consistent to relax this to not fail here or maybe just warn |
just want to point out: it should be a breaking change to change a rule's default option. |
Yeah I wish I'd opened the PR earlier to maybe target the v7 release |
I am not sure I agree here, as enabling In fact I would prefer to remove the rule from the recommended config, than making this change. A different option could be allowing assignment to specific variables? Would this work for you? |
This makes a lot of sense and I didn’t know it was possible! Let me take a look |
always-return
, enable ignoreLastCallback by defaultignoreAssignmentVariable
@scagood, @brettz9 @aladdin-add, can you take a look? |
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.
Besides the one suggestion, LGTM...
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.
I generally prefer this strategy I think!
Hey everyone, so I made the option recursive, which means it allows for assignments to nested properties like I had to use string manipulation since I'm not familiar with how else to achieve this, but it looks sound to me as a property can either be computed or not, and we take both into account |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #518 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 25 26 +1
Lines 649 719 +70
Branches 250 278 +28
=========================================
+ Hits 649 719 +70 ☔ View full report in Codecov by Sentry. |
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.
I would love to see some more tests, other than that, I think this is starting to take shape 💪
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.
LGTM...
Just as an idea for a future PR, it would seem to me a possibly even more common use browser case to allow node appending in the last promise, e.g.:
prom.then((newInfo) => {
document.body.append(toDom(newInfo));
})
But regardless, this PR LGTM...
Okay, so #518 (review) made a good point - we need to take into account both variations (computed or not computed) for each level of the passed variable names For instance, if It's not hard but it requires a little more complex logic or at least we need to determine how the config should behave To keep the implementation correct, what I propose is that we start with 1 level of nesting in the config - e.g., just |
PTAL with the current setting that only allows for simple var names |
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.
To keep the implementation correct, what I propose is that we start with 1 level of nesting in the config - e.g., just window or globalThis - and after discussing the details we make a follow-up PR to lift this restriction
I agree, I have left comments inline with that 😄
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.
I like the shape of this now!
Thank you for the awesome docs too 😀
@brettz9 Do you want to take another look at this PR? |
Sorry, is anyone else available? I've come into other work which is keeping me busy... |
Hey everyone, just checking in to see if we can get this merged soon Doing a lot of webdev these days and I keep bumping into this 🤣 |
ignoreAssignmentVariable
ignoreAssignmentVariable
option
Adds
ignoreAssignmentVariable
as discussed in #518 (comment)