Open Bug 1925856 Opened 1 year ago Updated 1 year ago

prefer-boolean-length-check incorrect example

Categories

(Developer Infrastructure :: Firefox Source Docs: Content, enhancement)

enhancement

Tracking

(Not tracked)

UNCONFIRMED

People

(Reporter: kernp25, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:131.0) Gecko/20100101 Firefox/131.0

Steps to reproduce:

  1. Open https://firefox-source-docs.mozilla.org/code-quality/lint/linters/eslint-plugin-mozilla/rules/prefer-boolean-length-check.html#examples-of-correct-code-for-this-rule

Actual results:

The first example if (foo.length && foo.length) {} I think is wrong. Should this not be if (foo.length) {}?

Flags: needinfo?(sledru)

Or should this be:
if (foo?.length) {}

or

if (foo && foo.length) {}

?

Redirecting to the JS coding style owner

Flags: needinfo?(standard8)
Flags: needinfo?(sledru)
Flags: needinfo?(dtownsend)

(In reply to kernp25 from comment #0)

The first example if (foo.length && foo.length) {} I think is wrong. Should this not be if (foo.length) {}?

This does indeed look strange. I think if (foo.length) {} would be good enough to replace it, since that reflects the first line of the incorrect code (though the two lists don't strictly match up).

Flags: needinfo?(standard8)
Flags: needinfo?(dtownsend)
You need to log in before you can comment on or make changes to this bug.