Skip to content
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

no-nested-ternary #567

Open
NovemLinguae opened this issue Apr 22, 2024 · 1 comment
Open

no-nested-ternary #567

NovemLinguae opened this issue Apr 22, 2024 · 1 comment

Comments

@NovemLinguae
Copy link

NovemLinguae commented Apr 22, 2024

Consider setting no-nested-ternary to warn or error. ESLint docs.

Would prevent stuff like this, which I find hard to read.

const test = sub ? ( sub.length ? 'test' : 'test2' ) : 'test3';

Here's some code searches. Codesearch 1. Codesearch 2. I excluded the folders modules, resources, lib, and dist, and files containing the word ".min.js". External code is much more likely to have nested ternaries due to minification or different code standards.

Would be good to keep it out of our codebase. I had several of these in Twinkle that I rewrote.

@edg2s
Copy link
Member

edg2s commented Apr 23, 2024

I think that's too subjective. Some may find a single line double ternary easier to read. I don't know if we need to be opinionated about it at such a high level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants