linter-bundle
Version:
Ready-to use bundle of linting tools, containing configurations for ESLint, stylelint and markdownlint.
30 lines (19 loc) • 929 B
Markdown
This rule enforces that ternary expressions are always wrapped in parentheses to improve readability and maintain consistency in code formatting.
```ts
const foo = bar ? 1 : 2;
const value = condition ? 'yes' : 'no';
```
```ts
const foo = (bar ? 1 : 2);
const value = (condition ? 'yes' : 'no');
```
- **Improved readability**: Wrapping ternary expressions in parentheses makes it clear that the entire expression is evaluated together.
- **Consistency**: Ensures a uniform style when using the ternary operator.
- **Avoids ambiguity**: Helps prevent misunderstandings in complex expressions.
This rule is fixable. It will automatically wrap ternary expressions in parentheses.