Make 'indent' rule configurable w.r.t ternary conditions
See original GitHub issueESLint version 3.0.0, babel-eslint parser
Rule: http://eslint.org/docs/rules/indent
Problem: Ternaries can be formatted better when used for multi-line conditionals, ‘indent’ rule currently does not allow this.
Example of the formatting pattern:
const object = cond
? {
foo: 'bar'
}
: {
baz: 'qux'
}
Notice how the braces line up and are easy to visually scan compared to this, which is what the ‘indent’ rule currently expects:
const object = cond
? {
foo: 'bar'
}
: {
baz: 'qux'
}
This goes for parenthetical expressions, multi-line function calls, and array literals as well.
Solution: I propose a new option for ‘indent’ called "multilineTernary"
that defaults to level 1 like the other opinionated ‘indent’ options, and which enforces the above pattern rather than the below.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:5
- Comments:10 (8 by maintainers)
Top Results From Across the Web
How to indent a long ternary condition in Php? - Stack Overflow
This is my ternary condition. The condition is a bit long, so the function call exceeds the 120 rule. $variable = (condition) ?...
Read more >indent - 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/eslint - Gitter
I am trying to set up linting for a project. The same set up worked a couple of weeks ago. There might be...
Read more >Untitled
... to 1.10.8 release - Fix race condition when cancelling a flash operation (rh ... (development) - core: make ipv6.addr-gen-mode default configurable (rh ......
Read more >https://perldoc.perl.org/5.6.1/B::Deparse.txt
configurable syntax highlighting: ANSI color, HTML, TeX, etc. ... $cx); } sub indent { my $self = shift; my $txt = shift; my...
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
If it’s a matter of time commitment, I’d be happy to make a pull request. It sounds like those who weighed in so far wouldn’t use this multi-line style to begin with, so changing the behavior of lines following infix-operator-begun lines wouldn’t affect them anyway. Can we instead have the discussion from the standpoint of assuming this style (which is valid), and then what indentation should be enforced for that style?
@Naoto-Ida Dirty fix is disabling rules with inline comments
I look forward for this indentation syntax, maybe in 2018 😅