-
-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # 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
Co-authored-by: Sebastian Good <2230835+scagood@users.noreply.github.com>
##### [v7.2.0](https://github.com/eslint-community/eslint-plugin-promise/blob/HEAD/CHANGELOG.md#720-2024-11-25) ##### 🌟 Features - **`no-callback-in-promise`:** add `timeoutsErr` option ([#514](eslint-community/eslint-plugin-promise#514)) ([907753f](eslint-community/eslint-plugin-promise@907753f)) - **`valid-params`:** add `exclude` option ([#515](eslint-community/eslint-plugin-promise#515)) ([7ff2cb9](eslint-community/eslint-plugin-promise@7ff2cb9)) - **always-return:** add `ignoreAssignmentVariable` option ([#518](eslint-community/eslint-plugin-promise#518)) ([701279c](eslint-community/eslint-plugin-promise@701279c)) - **catch-or-return:** add `allowThenStrict` option ([#522](eslint-community/eslint-plugin-promise#522)) ([53be970](eslint-community/eslint-plugin-promise@53be970)) - new rule `prefer-catch` ([#525](eslint-community/eslint-plugin-promise#525)) ([05c8a93](eslint-community/eslint-plugin-promise@05c8a93)) ##### 🩹 Fixes - permit appropriate computed member expressions and prototype access ([#535](eslint-community/eslint-plugin-promise#535)) ([4de9d43](eslint-community/eslint-plugin-promise@4de9d43)) ##### 🧹 Chores - **deps-dev:** bump eslint-plugin-jest from 28.6.0 to 28.8.0 ([#536](eslint-community/eslint-plugin-promise#536)) ([80741f8](eslint-community/eslint-plugin-promise@80741f8)) - **deps-dev:** bump eslint-plugin-n from 17.9.0 to 17.10.2 ([#529](eslint-community/eslint-plugin-promise#529)) ([a646010](eslint-community/eslint-plugin-promise@a646010)) - **deps-dev:** bump globals from 15.8.0 to 15.9.0 ([#527](eslint-community/eslint-plugin-promise#527)) ([b8afe92](eslint-community/eslint-plugin-promise@b8afe92)) - **deps-dev:** bump husky from 9.1.2 to 9.1.4 ([#524](eslint-community/eslint-plugin-promise#524)) ([b8fdb9f](eslint-community/eslint-plugin-promise@b8fdb9f)) - **deps-dev:** bump lint-staged from 15.2.7 to 15.2.8 ([#539](eslint-community/eslint-plugin-promise#539)) ([9e2528f](eslint-community/eslint-plugin-promise@9e2528f)) - **deps-dev:** update eslint-plugin-eslint-plugin to v6.3.0 ([#560](eslint-community/eslint-plugin-promise#560)) ([7459bd6](eslint-community/eslint-plugin-promise@7459bd6)) - **deps-dev:** update eslint-plugin-eslint-plugin to v6.3.1 ([#561](eslint-community/eslint-plugin-promise#561)) ([434c6fa](eslint-community/eslint-plugin-promise@434c6fa)) - **deps-dev:** update eslint-plugin-eslint-plugin to v6.3.2 ([#570](eslint-community/eslint-plugin-promise#570)) ([a849f64](eslint-community/eslint-plugin-promise@a849f64)) - **deps-dev:** update eslint-plugin-jest to v28.9.0 ([#565](eslint-community/eslint-plugin-promise#565)) ([cf213fb](eslint-community/eslint-plugin-promise@cf213fb)) - **deps-dev:** update eslint-plugin-n to v17.12.0 ([#563](eslint-community/eslint-plugin-promise#563)) ([d39e2f0](eslint-community/eslint-plugin-promise@d39e2f0)) - **deps-dev:** update eslint-plugin-n to v17.13.0 ([#566](eslint-community/eslint-plugin-promise#566)) ([b62f234](eslint-community/eslint-plugin-promise@b62f234)) - **deps-dev:** update eslint-plugin-n to v17.13.1 ([#567](eslint-community/eslint-plugin-promise#567)) ([266ddbb](eslint-community/eslint-plugin-promise@266ddbb)) - **deps-dev:** update eslint-plugin-n to v17.13.2 ([#569](eslint-community/eslint-plugin-promise#569)) ([390f51f](eslint-community/eslint-plugin-promise@390f51f)) - **deps-dev:** update npm-run-all2 to v6.2.4 ([#558](eslint-community/eslint-plugin-promise#558)) ([2cf1732](eslint-community/eslint-plugin-promise@2cf1732)) - **deps-dev:** update npm-run-all2 to v6.2.6 ([#559](eslint-community/eslint-plugin-promise#559)) ([dc32933](eslint-community/eslint-plugin-promise@dc32933)) - **deps:** switch from dependabot to renovate using shared eslint community configuration ([#537](eslint-community/eslint-plugin-promise#537)) ([30efed7](eslint-community/eslint-plugin-promise@30efed7)) - **deps:** update [@eslint-community/eslint-utils](https://github.com/eslint-community/eslint-utils) to v4.4.1 ([#562](eslint-community/eslint-plugin-promise#562)) ([5c3628d](eslint-community/eslint-plugin-promise@5c3628d)) - **deps:** update globals to v15.12.0 ([#564](eslint-community/eslint-plugin-promise#564)) ([c8632d1](eslint-community/eslint-plugin-promise@c8632d1)) - update [@typescript-eslint/parser](https://github.com/typescript-eslint/parser) to v7.18.0 ([#545](eslint-community/eslint-plugin-promise#545)) ([5744e60](eslint-community/eslint-plugin-promise@5744e60)) - update dependency eslint-plugin-n to v17.11.0 ([#556](eslint-community/eslint-plugin-promise#556)) ([bbd048b](eslint-community/eslint-plugin-promise@bbd048b)) - update dependency eslint-plugin-n to v17.11.1 ([#557](eslint-community/eslint-plugin-promise#557)) ([e545254](eslint-community/eslint-plugin-promise@e545254)) - update dependency globals to v15.11.0 ([#555](eslint-community/eslint-plugin-promise#555)) ([9151db8](eslint-community/eslint-plugin-promise@9151db8)) - update dependency typescript to v5.6.3 ([#554](eslint-community/eslint-plugin-promise#554)) ([ab55120](eslint-community/eslint-plugin-promise@ab55120)) - update eslint to v8.57.1 ([#551](eslint-community/eslint-plugin-promise#551)) ([38e2757](eslint-community/eslint-plugin-promise@38e2757)) - update eslint-plugin-jest to v28.8.3 ([#548](eslint-community/eslint-plugin-promise#548)) ([89f2578](eslint-community/eslint-plugin-promise@89f2578)) - update eslint-plugin-n to v17.10.3 ([#552](eslint-community/eslint-plugin-promise#552)) ([2d738fe](eslint-community/eslint-plugin-promise@2d738fe)) - update globals to v15.10.0 ([#553](eslint-community/eslint-plugin-promise#553)) ([b871314](eslint-community/eslint-plugin-promise@b871314)) - update husky to v9.1.6 ([#547](eslint-community/eslint-plugin-promise#547)) ([1e8d18f](eslint-community/eslint-plugin-promise@1e8d18f)) - update lint-staged to v15.2.10 ([#544](eslint-community/eslint-plugin-promise#544)) ([7d46b3b](eslint-community/eslint-plugin-promise@7d46b3b)) - update npm-run-all2 to v6.2.3 ([#550](eslint-community/eslint-plugin-promise#550)) ([14cd4c0](eslint-community/eslint-plugin-promise@14cd4c0)) - update typescript to ~5.6.0 ([#549](eslint-community/eslint-plugin-promise#549)) ([ebcdd8b](eslint-community/eslint-plugin-promise@ebcdd8b))
##### [v7.2.0](https://github.com/eslint-community/eslint-plugin-promise/blob/HEAD/CHANGELOG.md#720-2024-11-25) ##### 🌟 Features - **`no-callback-in-promise`:** add `timeoutsErr` option ([#514](eslint-community/eslint-plugin-promise#514)) ([907753f](eslint-community/eslint-plugin-promise@907753f)) - **`valid-params`:** add `exclude` option ([#515](eslint-community/eslint-plugin-promise#515)) ([7ff2cb9](eslint-community/eslint-plugin-promise@7ff2cb9)) - **always-return:** add `ignoreAssignmentVariable` option ([#518](eslint-community/eslint-plugin-promise#518)) ([701279c](eslint-community/eslint-plugin-promise@701279c)) - **catch-or-return:** add `allowThenStrict` option ([#522](eslint-community/eslint-plugin-promise#522)) ([53be970](eslint-community/eslint-plugin-promise@53be970)) - new rule `prefer-catch` ([#525](eslint-community/eslint-plugin-promise#525)) ([05c8a93](eslint-community/eslint-plugin-promise@05c8a93)) ##### 🩹 Fixes - permit appropriate computed member expressions and prototype access ([#535](eslint-community/eslint-plugin-promise#535)) ([4de9d43](eslint-community/eslint-plugin-promise@4de9d43)) ##### 🧹 Chores - **deps-dev:** bump eslint-plugin-jest from 28.6.0 to 28.8.0 ([#536](eslint-community/eslint-plugin-promise#536)) ([80741f8](eslint-community/eslint-plugin-promise@80741f8)) - **deps-dev:** bump eslint-plugin-n from 17.9.0 to 17.10.2 ([#529](eslint-community/eslint-plugin-promise#529)) ([a646010](eslint-community/eslint-plugin-promise@a646010)) - **deps-dev:** bump globals from 15.8.0 to 15.9.0 ([#527](eslint-community/eslint-plugin-promise#527)) ([b8afe92](eslint-community/eslint-plugin-promise@b8afe92)) - **deps-dev:** bump husky from 9.1.2 to 9.1.4 ([#524](eslint-community/eslint-plugin-promise#524)) ([b8fdb9f](eslint-community/eslint-plugin-promise@b8fdb9f)) - **deps-dev:** bump lint-staged from 15.2.7 to 15.2.8 ([#539](eslint-community/eslint-plugin-promise#539)) ([9e2528f](eslint-community/eslint-plugin-promise@9e2528f)) - **deps-dev:** update eslint-plugin-eslint-plugin to v6.3.0 ([#560](eslint-community/eslint-plugin-promise#560)) ([7459bd6](eslint-community/eslint-plugin-promise@7459bd6)) - **deps-dev:** update eslint-plugin-eslint-plugin to v6.3.1 ([#561](eslint-community/eslint-plugin-promise#561)) ([434c6fa](eslint-community/eslint-plugin-promise@434c6fa)) - **deps-dev:** update eslint-plugin-eslint-plugin to v6.3.2 ([#570](eslint-community/eslint-plugin-promise#570)) ([a849f64](eslint-community/eslint-plugin-promise@a849f64)) - **deps-dev:** update eslint-plugin-jest to v28.9.0 ([#565](eslint-community/eslint-plugin-promise#565)) ([cf213fb](eslint-community/eslint-plugin-promise@cf213fb)) - **deps-dev:** update eslint-plugin-n to v17.12.0 ([#563](eslint-community/eslint-plugin-promise#563)) ([d39e2f0](eslint-community/eslint-plugin-promise@d39e2f0)) - **deps-dev:** update eslint-plugin-n to v17.13.0 ([#566](eslint-community/eslint-plugin-promise#566)) ([b62f234](eslint-community/eslint-plugin-promise@b62f234)) - **deps-dev:** update eslint-plugin-n to v17.13.1 ([#567](eslint-community/eslint-plugin-promise#567)) ([266ddbb](eslint-community/eslint-plugin-promise@266ddbb)) - **deps-dev:** update eslint-plugin-n to v17.13.2 ([#569](eslint-community/eslint-plugin-promise#569)) ([390f51f](eslint-community/eslint-plugin-promise@390f51f)) - **deps-dev:** update npm-run-all2 to v6.2.4 ([#558](eslint-community/eslint-plugin-promise#558)) ([2cf1732](eslint-community/eslint-plugin-promise@2cf1732)) - **deps-dev:** update npm-run-all2 to v6.2.6 ([#559](eslint-community/eslint-plugin-promise#559)) ([dc32933](eslint-community/eslint-plugin-promise@dc32933)) - **deps:** switch from dependabot to renovate using shared eslint community configuration ([#537](eslint-community/eslint-plugin-promise#537)) ([30efed7](eslint-community/eslint-plugin-promise@30efed7)) - **deps:** update [@eslint-community/eslint-utils](https://github.com/eslint-community/eslint-utils) to v4.4.1 ([#562](eslint-community/eslint-plugin-promise#562)) ([5c3628d](eslint-community/eslint-plugin-promise@5c3628d)) - **deps:** update globals to v15.12.0 ([#564](eslint-community/eslint-plugin-promise#564)) ([c8632d1](eslint-community/eslint-plugin-promise@c8632d1)) - update [@typescript-eslint/parser](https://github.com/typescript-eslint/parser) to v7.18.0 ([#545](eslint-community/eslint-plugin-promise#545)) ([5744e60](eslint-community/eslint-plugin-promise@5744e60)) - update dependency eslint-plugin-n to v17.11.0 ([#556](eslint-community/eslint-plugin-promise#556)) ([bbd048b](eslint-community/eslint-plugin-promise@bbd048b)) - update dependency eslint-plugin-n to v17.11.1 ([#557](eslint-community/eslint-plugin-promise#557)) ([e545254](eslint-community/eslint-plugin-promise@e545254)) - update dependency globals to v15.11.0 ([#555](eslint-community/eslint-plugin-promise#555)) ([9151db8](eslint-community/eslint-plugin-promise@9151db8)) - update dependency typescript to v5.6.3 ([#554](eslint-community/eslint-plugin-promise#554)) ([ab55120](eslint-community/eslint-plugin-promise@ab55120)) - update eslint to v8.57.1 ([#551](eslint-community/eslint-plugin-promise#551)) ([38e2757](eslint-community/eslint-plugin-promise@38e2757)) - update eslint-plugin-jest to v28.8.3 ([#548](eslint-community/eslint-plugin-promise#548)) ([89f2578](eslint-community/eslint-plugin-promise@89f2578)) - update eslint-plugin-n to v17.10.3 ([#552](eslint-community/eslint-plugin-promise#552)) ([2d738fe](eslint-community/eslint-plugin-promise@2d738fe)) - update globals to v15.10.0 ([#553](eslint-community/eslint-plugin-promise#553)) ([b871314](eslint-community/eslint-plugin-promise@b871314)) - update husky to v9.1.6 ([#547](eslint-community/eslint-plugin-promise#547)) ([1e8d18f](eslint-community/eslint-plugin-promise@1e8d18f)) - update lint-staged to v15.2.10 ([#544](eslint-community/eslint-plugin-promise#544)) ([7d46b3b](eslint-community/eslint-plugin-promise@7d46b3b)) - update npm-run-all2 to v6.2.3 ([#550](eslint-community/eslint-plugin-promise#550)) ([14cd4c0](eslint-community/eslint-plugin-promise@14cd4c0)) - update typescript to ~5.6.0 ([#549](eslint-community/eslint-plugin-promise#549)) ([ebcdd8b](eslint-community/eslint-plugin-promise@ebcdd8b))
Adds
ignoreAssignmentVariable
as discussed in #518 (comment)