complete/strict-array-methods
💼 This rule is enabled in the ✅ recommended config.
📝 Requires boolean return types on some specific array methods.
💭 This rule requires type information.
Rule Details
Section titled “Rule Details”This rule targets the following Array methods:
Array.prototype.everyArray.prototype.filterArray.prototype.findArray.prototype.findIndexArray.prototype.findLastArray.prototype.findLastIndexArray.prototype.some
Normally, the
@typescript-eslint/strict-boolean-expressions
ESLint rule catches bugs where you are supposed to put a boolean value but
accidentally put something else. Unfortunately,
that rule does not catch this mistake when using array methods.
Thus, an additional ESLint rule is necessary to handle this.
// Badconst numbers: number[] = [];const filteredNumbers = numbers.filter((element) => { return element;});
// Goodconst numbers: number[] = [];const filteredNumbers = numbers.filter((element) => { return element !== 0;});Options
Section titled “Options”This rule is not configurable.
