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.

multiline-ternary doesn't check parentheses

See original GitHub issue

Tell us about your environment

  • ESLint Version: v7.0.0-alpha.3
  • Node Version: v12.14.0
  • npm Version: v6.13.4

What parser (default, Babel-ESLint, etc.) are you using?

Please show your full configuration:

Configuration
module.exports = {
    parserOptions: {
        ecmaVersion: 2015
    }
}

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

Online Demo

/*eslint multiline-ternary: ["error", "always"] */

(a
) ? b
  : c;
eslint index.js

What did you expect to happen?

It might be expected that parentheses should be treated as a part of the node, so in this case the rule should report that there’s a missing newline between test and consequent.

Some rules work that way (e.g., array-element-newline), some don’t (function-call-argument-newline), so I’m not sure if this is a bug.

What actually happened? Please include the actual, raw output from ESLint.

no errors

Are you willing to submit a pull request to fix this bug?

yes

The example was with "always", but the same issue exists with "always-multiline" and "never".

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
mdjermanoviccommented, Apr 18, 2020

Yes, if this is a bug the same logic would apply to the check between consequent and alternate…

1reaction
anikethsahacommented, Apr 18, 2020

I think this should be an error as well, right !

(a) 
  ? (b
    ): c; // <== error
Read more comments on GitHub >

github_iconTop Results From Across the Web

Can i use multiple line in ternary operator - Stack Overflow
The ternary conditional operator is an expression. ... Combine multiple statements in parenthesis separated by commas in between each line.
Read more >
Multi-line ternary in multi-line array: Indentation problem.
ArrayIndentation) insists that when using a multi-line ternary expression as an array value, all lines should be indented at the level of ...
Read more >
syntax - Ruby-style-guide - Womply - Relish
parentheses when the method doesn't accept any arguments. ... Use one expression per branch in a ternary operator. This ... check its existence...
Read more >
multiline-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 >
Ruby Style Guide
If you're into Rails or RSpec you might want to check out the complementary Ruby on ... Omit the parentheses when the method...
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