sonarjs/no-collection-size-mischeck
eslint-plugin-sonarjs
SuggestionRecommended
eslint.config.js
export default [
{
rules: {
"sonarjs/no-collection-size-mischeck": "error",
},
},
];Collection size and array length comparisons should make sense
if (someSet.size >= 0) {...} // Noncompliant
if (someMap.size < 0) {...} // Noncompliant
const result = someArray.length >= 0; // Noncompliantif (someSet.size > 0) {...}
if (someMap.size == 0) {...}
const result = someArray.length > 0;Examples from the ESLint documentation.
sonarjs/no-collection-size-mischeck
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/no-collection-size-mischeck": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Tests should not execute any code after "done()" is called
Regular expressions should not contain control characters
"switch" statements should not contain non-case labels
Lodash and Underscore.js debounced or throttled functions should not be recreated on every React render