Skip to content
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

feat: add no-unneeded-ternary rule #1034

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ah-yu
Copy link
Contributor

@ah-yu ah-yu commented Mar 31, 2022

Closes #1032

@lucsoft
Copy link

lucsoft commented Apr 6, 2022

im new to deno_lint but does this support the "quick fix" option from the LSP

@ah-yu
Copy link
Contributor Author

ah-yu commented Apr 6, 2022

@lucsoft No. See #1013

Comment on lines 3 to 17
It's a common mistake to use a conditional expression to select between two
Boolean values instead of using ! to convert the test to a Boolean.

### Invalid:

```typescript
const foo = condition ? true : false;
```

### Valid:

```typescript
const foo = condition ? x : y;
const foo = condition ? x : false;
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add more examples? I still don't understand the purpose of this rule just from examples

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I think I need to add some comments to make it more clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rule suggestion: Remove Unnecessary Conditional Expression
3 participants