-
-
Notifications
You must be signed in to change notification settings - Fork 511
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
💅 noUselessElse
recommendation is wrong
#1191
Comments
Hi @anonrig! Can you be a more specific about the bug / the expected result? Is it the removal of the comments? |
Hi @Conaclos, it removes the recommendations and also on line 116, it produces false JavaScript code:
|
I don't see any issue with the emitted JavaScript (leaving apart the removed comments that should definitively be preserved). Do you mean it is not correctly formatted? |
I'm facing the same issue, but end up I'm realizing it because the main if is using early return like this in your code if (declarationId.type === 'Identifier') {
return declarationId.name;
} So next line dont need to use else if, because if it true, it never run rest of code. replace this if (type === 'case A') {
return 'A'
} else if (type === 'case B') {
return 'B'
} else {
return 'C'
} to this if (type === 'case A') {
return 'A'
}
if (type === 'case B') {
return 'B'
}
return 'C' |
@spd789562 Do you think the rules' diagnostics could be improved? Any suggestions? |
Not sure about it, I got this lint error when use VScode, and it just say
But the problem is there has #no-useless-else is giving the good example though. |
Yeah maybe we can make our message better and explain why the |
We could add an explanation:
|
Sounds good to me! |
Environment information
Rule name
noUselessElse
Playground link
https://github.com/getsentry/sentry-javascript/blob/develop/rollup/plugins/extractPolyfillsPlugin.js
Expected result
The following file has invalid "FIXABLE" output:
https://github.com/getsentry/sentry-javascript/blob/develop/rollup/plugins/extractPolyfillsPlugin.js
Code of Conduct
The text was updated successfully, but these errors were encountered: