Rule Change: Array methods to highlight when return type does not match expected #17497
Closed
1 task done
Labels
archived due to age
This issue has been archived; please open a new issue for any further discussion
enhancement
This change enhances an existing feature of ESLint
needs info
Not enough information has been provided to triage this issue
rule
Relates to ESLint's core rules
What rule do you want to change?
array-callback-return
What change to do you want to make?
Implement suggestions
How do you think the change should be implemented?
A new option
Example code
What does the rule currently do for this code?
It can have it so that a return is required, but what is returned (the type) does not matter
What will the rule do after it's changed?
It will be able to highlight places where certain Array methods return values may be not what is expected.
Participation
Additional comments
In Typescript it was boolean before, they made it
unknown/any
. There has been some discussion on having stricter types but nothing has come out of it.My thinking is for the following methods:
Array.from - don't need
Array.every - boolean
Array.filter - boolean
Array.find - boolean
Array.findIndex - boolean
Array.findLast - boolean
Array.findLastIndex
Array.forEach - undefined
Array.map - TS covered if using generics!
Array.reduce - TS covered if using generics!
Array.reduceRight - TS covered if using generics!
Array.some - boolean
Array.sort - not sure
Array.toSorted - not sure
A bit worried in the difficulty of doing it for all Array methods in one PR but I also am not sure if you would allow doing it gradually as an option.
Should this also be the default, or an option? A part of me thinks why wouldn't someone want this, but maybe I haven't put enough thought into this.
The text was updated successfully, but these errors were encountered: