`unicorn/explicit-length-check` does not report when optional chaining
troywoy opened this issue · comments
Troy Hawley commented
When an optional chain is involved, such as data?.length
, the code is not correctly flagged by unicorn/explicit-length-check
.
// Does not error with "Use `.length > 0` when checking length is not zero.eslint(unicorn/explicit-length-check)"
if (data?.length) {
...
}
Issue was previously discussed here: #1263
codesandbox reproduction: https://codesandbox.io/p/devbox/h45722?file=%2Fsrc%2Findex.tsx%3A9%2C18