feat: add ternaryIndentStyle with structural indentation option#6
Open
steffen-heil-secforge wants to merge 1 commit intomainfrom
Open
feat: add ternaryIndentStyle with structural indentation option#6steffen-heil-secforge wants to merge 1 commit intomainfrom
steffen-heil-secforge wants to merge 1 commit intomainfrom
Conversation
1f673e9 to
20a8808
Compare
Adds a new configuration option `conditionalExpression.indentStyle` with two modes:
- "align" (default): All branches of nested ternaries align at the same indentation level
Example:
```
const result = condition1
? value1
: condition2
? value2
: value3;
```
- "structural": Nested ternaries increase indentation to reflect nesting structure
Example:
```
const result = condition1
? value1
: condition2
? value2
: value3;
```
The structural mode properly handles wrapper nodes (parentheses, type assertions,
satisfies expressions, non-null assertions) by traversing through them to find the
top-most conditional expression in the chain, ensuring consistent indentation.
Implementation includes:
- Configuration schema updates with new enum type
- Helper function to traverse wrapper nodes in structural mode
- Refactored conditional expression generation for both modes
- Comprehensive test specs for align and structural indentation styles
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
76f7583 to
f771199
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit adds a new configuration option
conditionalExpression.indentStylethat controls how ternary conditional expressions are indented.Options:
align(default): Aligns the ? and : operators under the condition, maintaining the current behaviorstructural: Uses structural indentation for nested ternary expressions, adding one level of indentation for each nested ternary to improve readability and avoid deep nesting issuesChanges:
🤖 Generated with Claude Code