Weird "no-nested-ternary" fix result
See original GitHub issueI ran xo --fix
and got this result. The brackets are a little excessive.
✖ 129:88 Do not nest ternary expressions. unicorn/no-nested-ternary
It swapped the first code block with the second.
const pluginName = isAbsolute ? pluginPath.slice(pluginPath.lastIndexOf('/') + 1) : (isNamespaced ? pluginPath.split('@')[1].split('/')[1] : pluginPath);
const pluginName = isAbsolute ? pluginPath.slice(pluginPath.lastIndexOf('/') + 1) : (((((((((((isNamespaced ? pluginPath.split('@')[1].split('/')[1] : pluginPath)))))))))));
Issue Analytics
- State:
- Created 3 years ago
- Comments:8
Top Results From Across the Web
Alternative to nested ternary operator in JS - Stack Overflow
18 Answers 18 · +1 for giving name to the conditions, which makes the ternary operator more readable; then, there is no need...
Read more >no-nested-ternary - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >eslint-plugin-unicorn/no-nested-ternary.md at main - GitHub
Disallow nested ternary expressions. This rule is enabled in the ✓ recommended config. This rule is automatically fixable by the --fix CLI option....
Read more >How to Read Nested Ternary Operators - Twisted Oak
Step 1: Fix Formatting ... First things first: the above code is terribly formatted. It reads like a run-on sentence, instead of exposing...
Read more >Rethinking the JavaScript ternary operator - James Sinclair
That's not the only weird thing about it though. ... Not to mention another ternary nested inside the final expression.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We’ll look into it.
You can also test my PR with
yarn add fisker/eslint-plugin-unicorn#issue-663
ornpm install fisker/eslint-plugin-unicorn#issue-663