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

Add no-useless-length-check rule #1398

Merged
merged 21 commits into from
Jul 3, 2021

Conversation

fisker
Copy link
Collaborator

@fisker fisker commented Jul 2, 2021

Not finished yet, nested logic operators are complicated.

Fixes #897

@fisker fisker marked this pull request as ready for review July 3, 2021 01:23
Comment on lines 7 to 8
'non-zero': '`Array#some()` returns `false` on empty array, the empty check is not needed.',
zero: '`Array#every()` returns `true` on empty array, the non-empty check is not needed.'
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
'non-zero': '`Array#some()` returns `false` on empty array, the empty check is not needed.',
zero: '`Array#every()` returns `true` on empty array, the non-empty check is not needed.'
'non-zero': 'The empty check is useless as `Array#some()` returns `false` for an empty array.',
zero: 'The non-empty check is useless as `Array#every()` returns `true` for an empty array.'

?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The message seems not right, I'll double-check the logic.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The message was wrong about the length check node, fixed.

@sindresorhus sindresorhus merged commit 1107455 into sindresorhus:main Jul 3, 2021
@fisker fisker deleted the `no-useless-length-check` branch July 3, 2021 15:59
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 proposal: no-unnecessary-length-check-before-some-every
2 participants