Prefer Functional Array Methods
When iterating an array to produce a derived value — a new array, a single accumulator, the first match, a boolean — use the corresponding higher-order method.…
$ prime install @web-style/rule-prefer-functional-array-methods Projection
Always in _index.xml · the agent never has to ask for this.
PreferFunctionalArrayMethods [rule] v0.1.0
When iterating an array to produce a derived value — a new array, a single accumulator, the first match, a boolean — use the corresponding higher-order method. The named method tells the reader what the loop is for in one word; a for loop with a hand-rolled accumulator buries that intent under index plumbing.
Loaded when retrieval picks the atom as adjacent / supporting.
PreferFunctionalArrayMethods [rule] v0.1.0
When iterating an array to produce a derived value — a new array, a single accumulator, the first match, a boolean — use the corresponding higher-order method. The named method tells the reader what the loop is for in one word; a for loop with a hand-rolled accumulator buries that intent under index plumbing.
Checks
- Mapping uses
array.map(fn), not aforloop pushing into a fresh array. - Filtering uses
array.filter(predicate). - Aggregating to a scalar uses
array.reduce(reducer, init). - Membership / first-match uses
array.some/array.find; existence usesarray.includes. - ESLint
no-iterator(forbiditerator/__iterator__) is enabled; teams may addno-restricted-syntaxto flag plainforover arrays.
Label
Use map / filter / reduce / find over hand-rolled for loops over arrays
Loaded when retrieval picks the atom as a focal / direct hit.
PreferFunctionalArrayMethods [rule] v0.1.0
When iterating an array to produce a derived value — a new array, a single accumulator, the first match, a boolean — use the corresponding higher-order method. The named method tells the reader what the loop is for in one word; a for loop with a hand-rolled accumulator buries that intent under index plumbing.
Checks
- Mapping uses
array.map(fn), not aforloop pushing into a fresh array. - Filtering uses
array.filter(predicate). - Aggregating to a scalar uses
array.reduce(reducer, init). - Membership / first-match uses
array.some/array.find; existence usesarray.includes. - ESLint
no-iterator(forbiditerator/__iterator__) is enabled; teams may addno-restricted-syntaxto flag plainforover arrays.
Label
Use map / filter / reduce / find over hand-rolled for loops over arrays
Label
Use map / filter / reduce / find over hand-rolled for loops over arrays
Source
prime-system/examples/web-style/primes/compiled/@web-style/rule-prefer-functional-array-methods/atom.yaml