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

explicit-length-check: Use 'non-zero': 'greater-than' by default #850

Merged
merged 2 commits into from Oct 6, 2020
Merged

explicit-length-check: Use 'non-zero': 'greater-than' by default #850

merged 2 commits into from Oct 6, 2020

Conversation

EvgenyOrekhov
Copy link
Contributor

@EvgenyOrekhov EvgenyOrekhov commented Oct 4, 2020

Note that this is a breaking change since the rule wasn't enforcing any non-zero comparison style by default before, but now it enforces the greater-than style.

Fixes #702

if (array.length === 0) {}
```


## Zero comparisons

Enforce comparison with `!== 0` when checking for zero length.
Enforce comparison with `=== 0` when checking for zero length.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe this was a typo because this section talks about zero comparisons. So I fixed it.

@@ -35,13 +35,13 @@ if (string.length < 1) {}
### Pass

```js
if (array.length !== 0) {}
if (array.length === 0) {}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe this was a typo because this section talks about zero comparisons. So I fixed it.

Copy link
Collaborator

@fisker fisker left a comment

Choose a reason for hiding this comment

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

Looks good.

@sindresorhus sindresorhus merged commit 7c5df5f into sindresorhus:master Oct 6, 2020
@EvgenyOrekhov EvgenyOrekhov deleted the 702-explicit-length-check-greater-than-by-default branch October 6, 2020 16:47
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.

Pick a default non-zero option for explicit-length-check
3 participants