[indent] Ternary doesn't allow extended indentation
See original GitHub issueTell us about your environment
- ESLint Version: whatever is on the DEMO on eslint.org, unfortunately it doesn’t show
- Node Version: n/a
- npm Version: m/a
- What parser (default, Babel-ESLint, etc.) are you using?
dunno, environments is set to
node
,es6
Please show your full configuration:
indent
is on
What did you do? Please include the actual source code causing the issue.
const foo = Math.random()
? {
a: 3,
}
: {};
What did you expect to happen? No warning. What actually happened? Please include the actual, raw output from ESLint. 4:5 - Expected indentation of 2 spaces but found 4. (indent)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:9
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to indent a long ternary condition in Php? - Stack Overflow
I have a long ternary condition in Php that exceeds the 120 hard rule. What would be the right indentation according to PSR...
Read more >Multi-line ternary in multi-line array: Indentation problem.
ArrayIndentation) insists that when using a multi-line ternary expression ... all lines should be indented at the level of the array values.
Read more >Linux kernel coding style
Rationale: The whole idea behind indentation is to clearly define where a block of control starts and ends. Especially when you've been looking...
Read more >PSR-12: Extended Coding Style - PHP-FIG
2.4 Indenting¶. Code MUST use an indent of 4 spaces for each indent level, and MUST NOT use tabs for indenting. 2.5 Keywords...
Read more >Remove braces from `if-else` where a single-line ternary could ...
I just want to (re-)open the discussion on it and also share my design insight about a block indenting design versus Rust's brace-delimited ......
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 Free
Top 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
I agree this is duplicate of #6606. We use this style pretty consistently, including with JSX and other expressions, where lint doesn’t error:
I see that this doesn’t work as well when the indentation isn’t two spaces and don’t really have an answer for that, as I personally don’t have experience with JS using different config. Perhaps if this was a configuration flag, it would only be used by people who have indent set to 2.
Closing because this is working as intended.