-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow flatTernaryExpressions option of indent rule #1421
Comments
Rather than relaxing the rule, I would prefer defining it better. But there doesn't seem to be an ESLint rule for indentation of ternary expressions other than the little @Alexsey just a suggestion here. Perhaps you'd like to contribute a whitespace (or at least indentation) rule to getify/eslint-plugin-proper-ternary#4 ? The maintainer labelled it as 'help wanted'. I have just suggested that we use that plugin in Standard: #1422. |
@mightyiam sorry, I have no experience with AST, so this task is probably not for me. But why do you think that relaxing the rule is not what we need here?
but this is not something that https://github.com/getify/eslint-plugin-proper-ternary can handle either. So relaxing the rule is the best we can have |
I'm not sure, @Alexsey. Please see #1424. If it is observed that the style that you requested to be able to use is the chosen style for that logic, then, relaxing might be the correct thing to do, until we have the rules available to enforce our chosen styles. Yet, for the sake of making one developer happy, I would not mind this rule being relaxed in the way you asked, as well, @Alexsey. As long as we follow up with style decisions. |
Ternaries are really dense, so the style we prefer in const a = b
? c
: d
? e
: f Or, you can use explicit if-elses: let a = f
if (b) {
a = c
} else if (d) {
a = e
} I'm not interested in reconsidering this decision at the moment, so I'm closing this issue. But feel free to continue discussion in this issue. |
What version of this package are you using? eslint-config-standard v14.1.0
What problem do you want to solve? Because switch/case in JavaScript is broken and while pattern matching in only a proposal code pattern under
flatTernaryExpressions
is one of a few ways to express long but trivial if/else chains in a clear way:What do you think is the correct solution to this problem?
Set
flatTernaryExpressions
option ofindent
rule totrue
Are you willing to submit a pull request to implement this change?
Yes
The text was updated successfully, but these errors were encountered: