{"id":19174861,"url":"https://github.com/knilink/ez-jscodeshift","last_synced_at":"2026-06-03T16:31:28.136Z","repository":{"id":255813837,"uuid":"172717178","full_name":"knilink/ez-jscodeshift","owner":"knilink","description":null,"archived":false,"fork":false,"pushed_at":"2019-03-18T14:07:41.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-23T00:44:34.757Z","etag":null,"topics":["codemod","jscodeshift"],"latest_commit_sha":null,"homepage":null,"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/knilink.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-26T13:30:39.000Z","updated_at":"2019-03-18T22:42:22.000Z","dependencies_parsed_at":"2024-09-07T08:39:09.747Z","dependency_job_id":"e09133a6-8bc6-478a-b882-0373b624f345","html_url":"https://github.com/knilink/ez-jscodeshift","commit_stats":null,"previous_names":["knilink/ez-jscodeshift"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/knilink/ez-jscodeshift","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knilink%2Fez-jscodeshift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knilink%2Fez-jscodeshift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knilink%2Fez-jscodeshift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knilink%2Fez-jscodeshift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knilink","download_url":"https://codeload.github.com/knilink/ez-jscodeshift/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knilink%2Fez-jscodeshift/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33874679,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-03T02:00:06.370Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["codemod","jscodeshift"],"created_at":"2024-11-09T10:19:28.690Z","updated_at":"2026-06-03T16:31:28.119Z","avatar_url":"https://github.com/knilink.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ez-jscodeshift\n\nez-jscodeshift is a wrapper around [jscodeshift](https://github.com/facebook/jscodeshift) to simple finding and replacing AST Nodes.\n\n## Install\n```\n$ npm install -g https://github.com/knilink/ez-jscodeshift.git\n```\n\n## Usage\n\nez-jscodeshift use [tagged template expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) to descript the filter and define node binding names.\n\nTo apply ez-jscodeshift, just simple wrap it over jscodeshift\n``` js\nconst jz = require('ez-jscodeshift')(require('jscodeshift'));\n```\n\n### Basic Example\n``` js\njz(`it('should work', () =\u003e {\n  assert.equal(foo(), 'bar');\n});`)\n  .ezFind`assert.equal(${'a'}, ${'b'})`\n  .ezReplaceWith`expect(${'a'}).to.equal(${'b'})`\n  .toSource()\n```\nOrigin\n``` js\nit('should work', () =\u003e {\n  assert.equal(foo(), 'bar');\n});\n```\nResult\n``` js\nit('should work', () =\u003e {\n  expect(foo()).to.equal('bar');\n});\n```\n\n### Custom filter\n``` js\njz(`expect(r1).to.equal('foo');\nexpect('bar').to.equal(r2);`)\n  .ezFind`expect(${['a', { type: 'Literal' }]}).to.equal(${'b'})`\n  .ezReplaceWith`expect(${'b'}).to.equal(${'a'})`\n  .toSource()\n```\nOrigin\n``` js\nexpect(r1).to.equal('foo');\nexpect('bar').to.equal(r2);\n```\nResult\n``` js\nexpect(r1).to.equal('foo');\nexpect(r2).to.equal('bar');\n```\n\n### Custom Binding\n``` js\njz('myObj.myFun(...[b,c,d])')\n  .ezFind`${'f'}(...${['a', { type: 'ArrayExpression', elements: (b) =\u003e ({ b }) }]})`\n  .ezReplaceWith`${$ =\u003e j.callExpression($.f.value, $.b.value)}`\n  .toSource();\n```\nOrigin\n``` js\nmyObj.myFun(...[b,c,d])\n```\nResult\n``` js\nmyObj.myFun(b, c, d)\n```\n\n### Block statement\n``` js\njz(`mylist.forEach(item=\u003e{\n  console.log(item);\n})`)\n  .ezFind`${'list'}.forEach((${'i'})=\u003e${'{body}'})`\n  .ezReplaceWith`for(const ${'i'} of ${'list'}) ${'{body}'}`\n  .toSource();\n```\nOrigin\n\n``` js\nmylist.forEach(item=\u003e{\n  console.log(item);\n})\n```\n\nResult\n\n``` js\nfor(const item of list) {\n  console.log(item);\n};\n```\n\n### Tagged template statement\n``` js\njz(\"tag`foo${'bar'}baz`\")\n  .ezFind`tag${'`t`'}`\n  .ezReplaceWith`tag2${'`t`'}`\n  .toSource()\n```\nOrigin\n``` js\ntag`foo${'bar'}baz`\n```\nResult\n``` js\ntag2`foo${'bar'}baz`;\n```\n\n### Other examples\n\n``` js\njz(`expect(foo,'my error description').to.equal('foo');`)\n  .ezFind`expect(${'a'},${'comment'}).to.equal(${'b'})`\n  .ezReplaceWith`expect(${'a'}).toBe(${'b'})`\n  .ezReplaceWith`${($, path) =\u003e {\n      const ast = path.value;\n      const commentAst = $.comment.value;\n      ast.expression.comments = [j.commentLine(' ' + commentAst.value)];\n      return ast;\n    }}`\n  .toSource()\n```\nOrigin\n``` js\nexpect(foo,'my error description').to.equal('foo');\n```\nResult\n``` js\n// my error description\nexpect(foo).toBe('foo');\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknilink%2Fez-jscodeshift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknilink%2Fez-jscodeshift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknilink%2Fez-jscodeshift/lists"}