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.

indent: bug in flatTernaryExpressions: true

See original GitHub issue

Tell us about your environment Linux Mint 18.3

  • ESLint Version: 5.13.0
  • Node Version: 8.11.2
  • npm Version: 5.6.0

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

Please show your full configuration:

Configuration
module.exports = {
  root: true,
  rules: {
    'no-undef': 0,
    'no-unused-vars': 0,
    'operator-linebreak': 0,
  }
}

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

// test1.js
/* eslint "indent": ["error", 2, {flatTernaryExpressions:true}] */

var a = foo
  ? bar : baz
  ? qux : boop
eslint ./test1.js

What did you expect to happen? no errors. Note the option flatTernaryExpressions:true in the config comment.

For this test, I made a simple eslintrc without rules, plugins, etc., but the same thing happens with the typedscript parser and the VS Code ESLint extension.

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

/home/xxxxxx/npm/eslint-config-standardize/test1.js 6:1 error Expected indentation of 4 spaces but found 2 indent

✖ 1 problem (1 error, 0 warnings) 1 error and 0 warnings potentially fixable with the --fix option.

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

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
mysticateacommented, Feb 15, 2019

Thank you for this issue.

Looks like the intentional behavior.

By design, flatTernaryExpressions:true option affects only when a condition and that result are on the same line. I.e.

var a =
  foo ? bar :
  baz ? qux :
  boop

The option is to support the style like Conditional Types.

type TypeName<T> =
    T extends string ? "string" :
    T extends number ? "number" :
    T extends boolean ? "boolean" :
    T extends undefined ? "undefined" :
    T extends Function ? "function" :
    "object";
0reactions
eslint-deprecated[bot]commented, Mar 19, 2019

It looks like the conversation is stalled here. As this is a question rather than an action item, I’m closing the issue. If you still need help, please send a message to our mailing list or chatroom. Thanks! [//]: # (auto-close)

Read more comments on GitHub >

github_iconTop Results From Across the Web

indent - ESLint - Pluggable JavaScript Linter
"flatTernaryExpressions": true ( false by default) requires no indentation for ternary expressions which are nested in other ternary expressions.
Read more >
Eslint expected indentation of 1 tab but found 4 spaces error
Try to disable indent inside .eslintrc.js file rules: { 'indent': 'off' }. this works fine for me.
Read more >
Adjust indents and spacing in Word - Microsoft Support
Change paragraph indents and spacing. Select one or more paragraphs that you want to adjust. Go to Home and then select the Paragraph...
Read more >
eslint/eslint - Gitter
The problem is that I don't use eslint-plugin-compat anywhere in the repository. ... Are you asking about the indentation of multiline expressions with ......
Read more >
Indentation Error in Python | How to Solve it - Edureka
While there is no quick fix to this problem, one thing that you need to keep in mind while trying to find a...
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