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.

prefer-ternary: option to ignore when multiple lines

See original GitHub issue

There should be an option for the rule prefer-ternary to ignore when there are multiple lines. I just updated my config, and it reported me that this was wrong:

if (process.platform === 'win32') {
    await exec(oneLine`
        A long line,
        which is on multiple lines
        etc etc
    `, { cwd: paths.project });
} else {
     await exec(oneLine`
          Same, but
          not on windows,
          etcetc
      `, { cwd: paths.project });
}

I think ternary expressions are really great for short lines, like in the examples on the docs, but for long lines like this, it should be skipped.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sindresorhuscommented, Jan 14, 2021

I think it would be more consistent with built-in ESLint rules to use: always / only-single-line (Like https://eslint.org/docs/rules/comma-dangle)

0reactions
szmarczakcommented, Jan 14, 2021

Agreed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use coalesce expression (IDE0029 and IDE0030) - .NET
Set the value of the associated option to specify whether null-coalescing expressions or ternary operator checking is preferred. The rule ...
Read more >
Grep ignore multiple lines - Stack Overflow
Is there a way with Grep to use the -v switch to ignore a line and the next number of lines ...
Read more >
eslint-plugin-unicorn/readme.md - UNPKG
2. 3, <img src="https://cloud.githubusercontent.com/assets/170270/18659176/1cc373d0-7f33-11e6-890f-0ba35362ee7e.jpg" width="180" align="right">.
Read more >
eslint-plugin-unicorn - npm
Name Description ✓ 🔧 💡 consistent‑destructuring Use destructured variables over properties. ✓ 🔧 💡 custom‑error‑definition Enforce correct Error subclassing. 🔧 empty‑brace‑spaces Enforce no spaces between braces....
Read more >
what's the best practice for conditional rendering inside a react ...
A few options at least for conditional stuff: ... I find they're great if you format them on multiple lines with indentation: {isRendered...
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