question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Weird "no-nested-ternary" fix result

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
fiskercommented, Apr 6, 2020

We’ll look into it.

0reactions
fiskercommented, Apr 7, 2020

You can also test my PR with yarn add fisker/eslint-plugin-unicorn#issue-663 or npm install fisker/eslint-plugin-unicorn#issue-663

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found