ESLint rules for pragmatic Ramda usage, refactoring and simplification
$ npm install --save-dev eslint eslint-plugin-ramda
Configure it in package.json.
{
"name": "my-awesome-project",
"eslintConfig": {
"env": {
"es6": true
},
"plugins": [
"ramda"
],
"rules": {
"ramda/always-simplification": "error",
"ramda/any-pass-simplification": "error",
"ramda/both-simplification": "error",
"ramda/complement-simplification": "error",
"ramda/compose-pipe-style": "error",
"ramda/compose-simplification": "error",
"ramda/cond-simplification": "error",
"ramda/either-simplification": "error",
"ramda/eq-by-simplification": "error",
"ramda/filter-simplification": "error",
"ramda/if-else-simplification": "error",
"ramda/map-simplification": "error",
"ramda/merge-simplification": "error",
"ramda/no-redundant-and": "error",
"ramda/no-redundant-not": "error",
"ramda/no-redundant-or": "error",
"ramda/pipe-simplification": "error",
"ramda/prefer-both-either": "error",
"ramda/prefer-complement": "error",
"ramda/prefer-ramda-boolean": "error",
"ramda/prop-satisfies-simplification": "error",
"ramda/reduce-simplification": "error",
"ramda/reject-simplification": "error",
"ramda/set-simplification": "error",
"ramda/unless-simplification": "error",
"ramda/when-simplification": "error"
}
}
}always-simplification- Detects whenalwaysusage can be replaced by a Ramda functionany-pass-simplification- Suggests simplifying list of negations inanyPassby single negation inallPassboth-simplification- Suggests transforming negatedbothconditions on negatedeithercomplement-simplification- Forbids confusingcomplement, suggesting a better onecompose-pipe-style- Enforcescomposefor single line expression andpipefor multilinecompose-simplification- Detects when a function that has the same behavior already existscond-simplification- Forbids usingcondwhenifElse,eitherorbothfitseither-simplification- Suggests transforming negatedeitherconditions on negatedbotheq-by-simplification- ForbidseqBy(prop(_))and suggestseqPropsfilter-simplification- Forbids using negatedfilterand suggestsrejectif-else-simplification- Suggestswhenandunlesswhen it is possible to replacemap-simplification- Forbidsmap(prop(_))and suggestspluckmerge-simplification- Forbidsmergewhenassocfitsno-redundant-and- Forbidsandwith 2 parameters in favor of&&no-redundant-not- Forbidsnotwith 1 parameter in favor of!no-redundant-or- Forbidsorwith 2 parameters in favor of||pipe-simplification- Detects when a function that has the same behavior already existsprefer-both-either- Enforces usingboth/eitherinstead ofallPass/anyPasswith a list of only two predicatesprefer-complement- Enforces usingcomplementinstead of compositions usingnotprefer-ramda-boolean- Enforces usingR.TandR.Finstead of explicit functionsprop-satisfies-simplification- Detects when can replacepropSatisfiesby more simple functionsreduce-simplification- Detects when can replacereducebysumorproductreject-simplification- Forbids using negatedrejectand suggestsfilterset-simplification- Forbids usingsetwithlensPropin favor ofassocunless-simplification- Forbids using negatedunlessand suggestswhenwhen-simplification- Forbids using negatedwhenand suggestsunless
This plugin exports a recommended configuration that enforces good practices.
To enable this configuration, use the extends property in your package.json.
{
"name": "my-awesome-project",
"eslintConfig": {
"plugins": [
"ramda"
],
"extends": "plugin:ramda/recommended"
}
}See ESLint documentation for more information about extending configuration files.
MIT © @haskellcamargo and @lo1tuma