{"id":29189371,"url":"https://github.com/coderaiser/estree-to-babel","last_synced_at":"2025-10-26T07:36:28.915Z","repository":{"id":50220855,"uuid":"163530864","full_name":"coderaiser/estree-to-babel","owner":"coderaiser","description":"convert estree ast to babel","archived":false,"fork":false,"pushed_at":"2025-05-29T19:31:46.000Z","size":240,"stargazers_count":35,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-30T02:39:32.642Z","etag":null,"topics":["ast","babel","cherow","espree","estree","javascript","nodejs","parser"],"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/coderaiser.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","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,"zenodo":null}},"created_at":"2018-12-29T18:02:08.000Z","updated_at":"2025-05-29T19:31:48.000Z","dependencies_parsed_at":"2025-06-30T02:36:04.318Z","dependency_job_id":"6761f471-499a-45d0-a883-cbf141187b4f","html_url":"https://github.com/coderaiser/estree-to-babel","commit_stats":{"total_commits":241,"total_committers":6,"mean_commits":"40.166666666666664","dds":0.09958506224066388,"last_synced_commit":"0772a31b0aebb1474831933885f33b4bdad1988b"},"previous_names":[],"tags_count":62,"template":false,"template_full_name":null,"purl":"pkg:github/coderaiser/estree-to-babel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderaiser%2Festree-to-babel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderaiser%2Festree-to-babel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderaiser%2Festree-to-babel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderaiser%2Festree-to-babel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coderaiser","download_url":"https://codeload.github.com/coderaiser/estree-to-babel/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderaiser%2Festree-to-babel/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262932999,"owners_count":23386771,"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":["ast","babel","cherow","espree","estree","javascript","nodejs","parser"],"created_at":"2025-07-01T23:07:21.124Z","updated_at":"2025-10-26T07:36:23.894Z","avatar_url":"https://github.com/coderaiser.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Estree-to-babel [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]\n\n[NPMIMGURL]: https://img.shields.io/npm/v/estree-to-babel.svg?style=flat\u0026longCache=true\n[BuildStatusURL]: https://github.com/coderaiser/estree-to-babel/actions?query=workflow%3A%22Node+CI%22 \"Build Status\"\n[BuildStatusIMGURL]: https://github.com/coderaiser/estree-to-babel/workflows/Node%20CI/badge.svg\n[NPMURL]: https://npmjs.org/package/estree-to-babel \"npm\"\n[BuildStatusURL]: https://travis-ci.org/coderaiser/estree-to-babel \"Build Status\"\n[CoverageURL]: https://coveralls.io/github/coderaiser/estree-to-babel?branch=master\n[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/estree-to-babel/badge.svg?branch=master\u0026service=github\n\nConvert [`ESTree`](https://github.com/estree/estree)-compatible `JavaScript AST` to [`Babel AST`](https://github.com/babel/babel/blob/main/packages/babel-parser/ast/spec.md).\n\nTo use parsers like:\n\n- [`acorn`](https://github.com/acornjs/acorn)\n- [`cherow`](https://github.com/cherow/cherow)\n- [`espree`](https://github.com/eslint/espree)\n- etc...\n\nWith `babel` tools like:\n\n- [`@babel/traverse`](https://babeljs.io/docs/en/babel-traverse)\n- [`@babel/types`](https://babeljs.io/docs/en/babel-types)\n- etc...\n\nThe thing is [`@babel/parser`](https://babeljs.io/docs/en/babel-parser) has a [little differences](https://babeljs.io/docs/en/babel-parser#output) with `estree` standard:\n\n- `Property` of `ObjectExpression` and `ObjectPattern` called `ObjectProperty`;\n- `FunctionExpression` of a `Property` located in `ObjectMethod` node;\n- `File` node;\n- `StringLiteral`, `NumericLiteral`, `NullLiteral`, `RegExpLiteral`, `BooleanLiteral` instead of `Literal`;\n- `ClassMethod` instead of `MethodDefinition`;\n- `ClassPrivateMethod`;\n- `ClassPrivateName` stores name as `Identifier` in `id` field;\n- `ClassPrivateProperty` instead of `FieldDefinition`;\n- `OptionalMemberExpression` and `OptionalCallExpression` instead of `ChainExpression`;\n- `ImportDeclaration` and `ExportNamedDeclaration` has `attributes`;\n- `JSXText` has `extra` field;\n- `extra.parenthesized=true` instead of `ParenthesizedExpression`;\n- etc...\n\nAlso [`@babel/parser`](https://babeljs.io/docs/en/babel-parser) has differences with [`typescript-estree`](https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/typescript-estree):\n\n- `ClassPrivateProperty` instead of `PropertyDefinition` when `key.type=PrivateName`;\n- `ClasseProperty` instead of `PropertyDefinition` when `key.type=Identifier`;\n- `PrivateName` instead of `PrivateIdentifier`;\n- `TSQualifiedName` instead of `MemberExpression`  in `TSInterfaceHeritage`;\n- `TSDeclaredMethod` with `abstract=true` instead of `TSAbstractMethodDefinition`;\n- `extra.parenthesized=true` instead of `TSParenthesizedType`;\n- etc...\n\n`estree-to-babel` aims to smooth this differences.\n\n## Install\n\n```\nnpm i estree-to-babel\n```\n\n### Example\n\n```js\nconst cherow = require('cherow');\nconst toBabel = require('estree-to-babel');\nconst traverse = require('@babel/traverse').default;\n\nconst ast = toBabel(cherow.parse(`\n    const f = ({a}) =\u003e a;\n`));\n\ntraverse({\n    ObjectProperty(path) {\n        console.log(path.value.name);\n        // output\n        'a';\n    },\n});\n```\n\nYou can provide options:\n\n```js\nimport * as cherow from 'cherow';\nimport {estreeToBabel} from 'estree-to-babel';\nimport traverse from '@babel/traverse';\n\nconst options = {\n    convertParens: false,\n};\n\nconst ast = estreeToBabel(cherow.parse(`\n    (a = b)\n`), options);\n\ntraverse({\n    AssignmentExpression(path) {\n        console.log(path.parentPath.type);\n        // output\n        'ParenthesizedExpression';\n    },\n});\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderaiser%2Festree-to-babel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderaiser%2Festree-to-babel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderaiser%2Festree-to-babel/lists"}