Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Use Array.some for boolean membership checks instead of find
When you only need to know whether any element matches, use .some (returns a boolean) rather than .find (returns the element).
Bad example
| 1 | const enabled = !!settings.find(s => allowed.includes(s)); |
Explanation (EN)
Returning the matched item and coercing it can misreport a falsy match; some expresses existence directly.
Objašnjenje (HR)
Good example
| 1 | const enabled = settings.some(s => allowed.includes(s)); |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
Use some when the caller needs only existence and the predicate visits equivalent values in the supported collection shape.
Exceptions / Tradeoffs (EN)
Keep find when the matching value is needed. Truthiness of a found zero, false or empty string does not express existence; inspect sparse arrays and predicate side effects before changing iteration.