You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The conditional expression can use some decisions regarding where lines are broken and where indentation is placed, I feel. For example, the following different styles are currently possible:
The way I see it, we already allow too many different styles. Ideally, according to the mission of StandardJS, we'd decide on a certain style and enforce it.
Ternary expressions seem a bit complicated in terms of possibilities of where to place the line breaks and how much to indent in which case. And I don't know whether we have the theory of that figured out. I assume @feross has his own habits.
I think a good first task would be to break down the various options into a list and post it here, with examples.
The Conditional Expression has the following syntax:
Simplified: condition ? then : else
These 5 parts:
condition
?
then
:
else
If we are to solve the styling of the ternary, perhaps we should first limit the ternary in some ways, using the #1422 plugin. That way, we have less things to think about in the scope of line breaks and indentation. So, I'm going to mark this as blocked by #1422.
The text was updated successfully, but these errors were encountered:
Both provided examples looks good depends on parts length: use first when condition and then are short and use second if condition and then are long so you want to split them in to separate lines, so it would be easier to read. The same logic as for any other binary operator e.g. ||:
const a = foo || getA()
const b = await (Promise.all(bar.map(fetch).find(v => v % 15)) ||
generateBValueFunctionWithVeryLongName())
The conditional expression can use some decisions regarding where lines are broken and where indentation is placed, I feel. For example, the following different styles are currently possible:
This, as well:
The way I see it, we already allow too many different styles. Ideally, according to the mission of StandardJS, we'd decide on a certain style and enforce it.
Ternary expressions seem a bit complicated in terms of possibilities of where to place the line breaks and how much to indent in which case. And I don't know whether we have the theory of that figured out. I assume @feross has his own habits.
I think a good first task would be to break down the various options into a list and post it here, with examples.
The Conditional Expression has the following syntax:
Simplified:
condition ? then : else
These 5 parts:
condition
?
then
:
else
If we are to solve the styling of the ternary, perhaps we should first limit the ternary in some ways, using the #1422 plugin. That way, we have less things to think about in the scope of line breaks and indentation. So, I'm going to mark this as blocked by #1422.
The text was updated successfully, but these errors were encountered: