Please include the ability to configure indent on conditional expressions
See original GitHub issueWhat rule do you want to change? indent
Does this change cause the rule to produce more or fewer warnings? more
How will the change be implemented? (New option, new default behavior, etc.)? new option
Please provide some example code that this change will affect:
Existing:
'indent': [
'error',
4,
{
'CallExpression': {
'arguments': 2,
},
'FunctionDeclaration': {
'body': 1,
'parameters': 2,
},
'FunctionExpression': {
'body': 1,
'parameters': 2,
},
'MemberExpression': 2,
'ObjectExpression': 1,
'SwitchCase': 1,
'ignoredNodes': [
'ConditionalExpression',
],
},
],
Desired (Example):
'indent': [
'error',
4,
{
'CallExpression': {
'arguments': 2,
},
'FunctionDeclaration': {
'body': 1,
'parameters': 2,
},
'FunctionExpression': {
'body': 1,
'parameters': 2,
},
'MemberExpression': 2,
'ObjectExpression': 1,
'SwitchCase': 1,
'ConditionalExpression: 1,
},
],
What does the rule currently do for this code? The only way to configure indent behavior for conditional (ternary) expressions is to ignore them completely
What will the rule do after it’s changed? Conditional expressions will be configurable, just as every other kind of expression. At the very least, it should be possible to automatically bring conditional expressions into conformance with the rest of the code base, which it does not currently seem to do.
Are you willing to submit a pull request to implement this change? I have no idea how to do that. Maybe if you can give me enough of a description on how to make it happen, I could give it a shot, but I am not familiar at all with JS, so my code might be less than great.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
These seem like two separate issues to me - do you mind creating a separate issue for the latter one?
I don’t think we’re quite on the same page. The
indent
rule enforces indentation but doesn’t add newlines. You can see an example here.It sounds like what you’re looking for is the following:
Unfortunately, it looks like there wasn’t enough interest from the team or community to implement this change. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to reach accepted status after 21 days tend to never be accepted, and as such, we close those issues. This doesn’t mean the idea isn’t interesting or useful, just that it’s not something the team can commit to.
Thanks for contributing to ESLint and we appreciate your understanding.