-
Notifications
You must be signed in to change notification settings - Fork 0
False "duplicate ternary conditions" #9
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
Comments
Hi there Mario, thanks for using this plugin and opening an issue, I will have a look into this and get back to you. From what I can see your ternary conditions look fine so it might be a problem with how I am passing objects, or when the ternary operator is repeated inside one of the ternary conditions. Will get back to you latest by next week! Until then it might be worth configuring the no-unreachable rule as a warning or turning it off temporarily. Apologies for any inconvenience caused. |
Hi @crystalfp I got around to testing these. Under the default rules I cannot get an error to trigger using the samples you provided using JavaScript:
I tested this by adding those three lines to the valid tests part of the no-unreachable tests file. To help me debug the issue, could you:
I am also pushing an update today since I found a bug with the depth option not having been implemented, but I haven't touched the no-unreachable rule so I can't imagine updating will fix it for you. Still, v2.0.0 of the plugin is out today so you try updating just in case :) |
Thanks @GrayedFox ! I will do soon after fixing another annoying & pervasive problem ( no more supported). In any case, I happy eslint my Typescript code after configuring the right parser. |
@GrayedFox I tested the latest version, the false positive continues for Configuration: Typescript file, eslint.yaml attached below.
|
Hello again Mario thanks for posting that. I can see you are using the ternary plugin with the recommended settings (i.e. you have not tweaked the rules). When I have time I will try and reproduce this result using ESLint, the typescript eslint parser, and just the ternary plugin installed. Just to be super clear: the files you are linting are the typescript files before they have been transpiled into JavaScript, right? Because I am pretty sure there is no point linting the files output from the TypeScript parser (not super familiar with TS but I assume that's how it works). Thanks again for your input. |
Yes, I use ESlint on the typescript files. |
I am getting the issue shown in the errors above. That is, the |
I installed the plugin and received plenty of error in my Typescript project. For example the following lines are marked as "Duplicate ternary conditions" when really there is a single ternary:
Or even this, where there are two independent near ternaries:
Seems the plugin raises this error when the same variable is used as ternary condition and inside the alternatives.
I don't see how, but if these are legitimate errors, then the rule documentation needs an update.
Thanks for clarifying!
mario
The text was updated successfully, but these errors were encountered: