eslint-plugin-lodash-fp: `prefer-flat-map` being erroneously triggered
The rule prefer-flat-map is being trigger with the following line and I don’t know why.
const filterOut = _.flow(_.get('foods'), _.reject('tomato'), _.reject('strawberry'), _.reject({ id: 'SUGARID' }))
Thanks 🎈
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 16 (9 by maintainers)
Commits related to this issue
- Improve error message from `prefer-composition-grouping` (fixes #30) — committed to jfmengels/eslint-plugin-lodash-fp by jfmengels 8 years ago
Landed in 4473a0e
Ok cool, let’s go with that then 😃, will do that tonight
That’s perfect. Thank you!
Ha! Found it!
It’s not actually the
prefer-flat-maprule that has an error, but rather theprefer-composition-groupingrule that is triggered, and that it currently gives the same error message asprefer-flat-map, and the same problem exists forno-extraneous-iteratee-args. Ugh… shameful… That’s what you guess when you develop the logic first and then the error message and have no review 😄.I’ll fix that tonight so that both of the rules return a proper error message.
Then, to come back to your error, you have multiple of the same operations (among
map,filterandreject) next to each other, which can be improved upon.I know that when you use some compiled functional languages, the former is compiled into the latter, as it is more efficient for processing, and it may in some cases be easier to read, especially if you give the function a nice name. That’s why I proposed this rule. I did not know/think of the property shorthand though.
See https://github.com/jfmengels/eslint-plugin-lodash-fp/blob/master/docs/rules/prefer-composition-grouping.md for more details.