{"id":18819657,"url":"https://github.com/xodio/eslint-plugin-xod-fp","last_synced_at":"2026-04-28T18:03:51.981Z","repository":{"id":57230327,"uuid":"79572719","full_name":"xodio/eslint-plugin-xod-fp","owner":"xodio","description":"Limit the chaos while doing FP in JS","archived":false,"fork":false,"pushed_at":"2017-01-23T16:47:53.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-02T13:07:26.089Z","etag":null,"topics":["eslint","eslint-rules","functional-programming","ramda"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xodio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-20T15:51:32.000Z","updated_at":"2017-02-14T15:16:33.000Z","dependencies_parsed_at":"2022-09-14T21:21:59.196Z","dependency_job_id":null,"html_url":"https://github.com/xodio/eslint-plugin-xod-fp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xodio%2Feslint-plugin-xod-fp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xodio%2Feslint-plugin-xod-fp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xodio%2Feslint-plugin-xod-fp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xodio%2Feslint-plugin-xod-fp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xodio","download_url":"https://codeload.github.com/xodio/eslint-plugin-xod-fp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239758830,"owners_count":19692033,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eslint","eslint-rules","functional-programming","ramda"],"created_at":"2024-11-08T00:24:20.626Z","updated_at":"2026-04-28T18:03:46.948Z","avatar_url":"https://github.com/xodio.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# eslint-plugin-xod-fp\n\nESLint plugins to check code written in functional style with\n[Ramda](http://ramdajs.com/).\n\n## Installation\n\nYou'll first need to install [ESLint](http://eslint.org):\n\n```\n$ npm i eslint --save-dev\n```\n\nNext, install `eslint-plugin-xod-fp`:\n\n```\n$ npm install eslint-plugin-xod-fp --save-dev\n```\n\n**Note:** If you installed ESLint globally (using the `-g` flag) then you must\nalso install `eslint-plugin-xod-fp` globally.\n\n## Usage\n\nAdd `xod-ramda` to the plugins section of your `.eslintrc` configuration file.\nYou can omit the `eslint-plugin-` prefix:\n\n```json\n{\n  \"plugins\": [\n    \"xod-fp\"\n  ]\n}\n```\n\nThen configure the rules you want to use under the rules section.\n\n```json\n{\n  \"rules\": {\n    \"xod-fp/max-composition-depth\": [ \"error\", 5 ],\n  }\n}\n```\n\n## Supported Rules\n\n* `max-composition-depth`: limit compositional calls nesting\n\n### Rule: `max-composition-depth`\n\nEnsure that function compositions are not too deep.\n\n#### Valid\n```js\n// :: Node -\u003e Boolean\nconst isCallExpression = R.propEq('type', 'CallExpression');\n\n// :: Node -\u003e Boolean\nconst isArrowFunctionExpression = R.propEq('type', 'ArrowFunctionExpression');\n\n// :: Node -\u003e Boolean\nconst isCurry = R.allPass([\n  R.propEq('type', 'CallExpression'),\n  R.pathEq(['callee', 'type'], 'MemberExpression'),\n  R.pathEq(['callee', 'object', 'type'], 'Identifier'),\n  R.pathEq(['callee', 'object', 'name'], 'R'),\n  R.pathEq(['callee', 'property', 'type'], 'Identifier'),\n  R.pathEq(['callee', 'property', 'name'], 'curry'),\n]);\n\n// :: Node -\u003e Boolean\nconst isCallNotCurry = R.both(\n  isCallExpression,\n  R.complement(isCurry)\n);\n\n// :: Options -\u003e Node -\u003e Boolean\nconst isNestingExpression = opts =\u003e R.anyPass([\n  opts.ignoreCurry ? isCallNotCurry : isCallExpression,\n  opts.ignoreArrow ? R.F : isArrowFunctionExpression,\n]);\n\n// :: Node -\u003e [Node] -- a chain of parents to the root\nconst parents = R.ifElse(\n  R.prop('parent'),\n  R.compose(parent =\u003e R.concat([parent], parents(parent)), R.prop('parent')),\n  R.always([])\n);\n\n// :: Options -\u003e Node -\u003e Number\nconst nestingDepth = R.curry((opts, node) =\u003e R.compose(\n  R.length,\n  R.uniq,\n  R.map(R.prop('start')),\n  R.filter(isNestingExpression(opts)),\n  parents\n)(node));\n```\n\n#### Invalid\n```js\n// :: Options -\u003e Node -\u003e Number\n// -- No R.compose (depth is 7)\nconst nestingDepth = R.curry((opts, node) =\u003e\n  R.length(R.uniq(R.map(\n    R.prop('start'), R.filter(isNestingExpression(opts)), parents(node)\n  )))\n);\n\n// :: Options -\u003e Node -\u003e Number\n// -- Too complex inlining (depth is 8)\nconst nestingDepth = R.curry((opts, node) =\u003e R.compose(\n  R.length,\n  R.uniq,\n  R.map(R.prop('start')),\n  R.filter(opts =\u003e R.anyPass([\n      opts.ignoreCurry ? R.allPass([\n        R.propEq('type', 'CallExpression'),\n        R.pathEq(['callee', 'type'], 'MemberExpression'),\n        R.pathEq(['callee', 'object', 'type'], 'Identifier'),\n        R.pathEq(['callee', 'object', 'name'], 'R'),\n        R.pathEq(['callee', 'property', 'type'], 'Identifier'),\n        R.pathEq(['callee', 'property', 'name'], 'curry'),\n      ]) : R.propEq('type', 'CallExpression'),\n      opts.ignoreArrow ? R.F : R.propEq('type', 'ArrowFunctionExpression'),\n  ])),\n  R.ifElse(\n    R.prop('parent'),\n    R.compose(parent =\u003e R.concat([parent], parents(parent)), R.prop('parent')),\n    R.always([])\n  )\n)(node));\n```\n\n#### Options\n\n#### `max`\n\nDefaults to 4.\n\nMaximal nesting depth. Nested function call or arrow function expression\nincrement the depth.\n\n#### `ignoreArrow`\n\nDefaults to false.\n\nPass `{ ignoreArrow: true }` to not to take arrow functions into account when\ncounting the depth.\n\n#### `ignoreCurry`\n\nDefaults to false.\n\nPass `{ ignoreCurry: true }` to not to take `R.curry` calls into account when\ncounting the depth.\n\nCalling `R.curry` is just a fighting with JavaScript to make it more\nFP-compatible. If you see `R.curry` you probably would not think about it\nat all trying to understand what an overall function does. So it is a good\nidea to ignore currying in depth calculation as well.\n\n#### `ignoreMocha`\n\nDefaults to false.\n\nPass `{ ignoreMocha: true }` to not to take `it` and `describe` calls of\n[Mocha](https://mochajs.org/) into account when counting the depth. Child\narrow functions of `it` and `describe` will be ignored as well.\n\nMocha’s functions are part of testing DSL and are not part of functions logic,\nso do not add to a function complexity thus can be ignored.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxodio%2Feslint-plugin-xod-fp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxodio%2Feslint-plugin-xod-fp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxodio%2Feslint-plugin-xod-fp/lists"}