-
-
Notifications
You must be signed in to change notification settings - Fork 192
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
10$: Warn on if("x"||"y"), case "x"||"y":, etc. #953
Comments
Could I ask what coding language this is expected to be done in? |
@ybl3 C++. The patch would probably look like this:
|
Cool, I claim this for-hire task. I expect payment after I complete this task. I will email the quick-lint-js team if I am assigned this task. |
@ybl3 Do you need any help with this task? |
Is this warning only for || conditions, or for all conditions with string literals? Also, should I consider all string literals, including empty ones ("")? Also, is this warning more geared towards someone that accidentally put quotation marks around a variable name, or just for preventing unnecessary code, or both? |
Good question. I think we should do just
Yes. We might want to emit different messages in these different cases.
For For |
if ("x" === s || "y" === s) { switch (s) { |
The issue lies in the incorrect use of logical operators || within the if statement and the switch case. In C++, logical operators like || are used for combining conditions, but they cannot be directly used to compare values as done in the code snippet. |
The text was updated successfully, but these errors were encountered: