-
Notifications
You must be signed in to change notification settings - Fork 889
Allow fast null checks in no-unused-expression rule does not cover some cases #4021
Comments
This pattern does not work either:
|
@alamothe that is effectively the same pattern the issue raised. It doesn't matter if the nullable thing is a variable, or a property inside an object. |
Right, sorry about that, I guess my point was that the pattern is fairly common inside React. |
|
@XeniaSiskaki why would you expect that to work? If |
It's the short way of saying |
tslint complains if the type of if (x) y!(); But my point is, this is not an issue with TS, and it's not related to the issue I brought up here, which is a real thing tslint could improve. |
☠️ TSLint's time has come! ☠️ TSLint is no longer accepting most feature requests per #4534. See typescript-eslint.io for the new, shiny way to lint your TypeScript code with ESLint. ✨ It was a pleasure open sourcing with you all! |
🤖 Beep boop! 👉 TSLint is deprecated 👈 (#4534) and you should switch to typescript-eslint! 🤖 🔒 This issue is being locked to prevent further unnecessary discussions. Thank you! 👋 |
The
allow-fast-null-checks
option for theno-unused-expression
rule, which was added in #1638, is currently not covering all cases. Today it's only meant for allowing expressions that check if a variable is truth before calling a method on that variable:I propose that it should also cover cases that check if a variable is truth before calling it as a function:
And perhaps there are other cases as well. If someone can think of any, please add them here so it can be covered in a future PR for this issue as well.
The text was updated successfully, but these errors were encountered: