{"name":"estree-to-babel","version":"10.3.0","keywords":["ast","convert","estree","babel","espree"],"author":{"url":"https://github.com/coderaiser","name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"license":"MIT","_id":"estree-to-babel@10.3.0","homepage":"http://github.com/coderaiser/estree-to-babel","bugs":{"url":"https://github.com/coderaiser/estree-to-babel/issues"},"dist":{"shasum":"30c59e424c0542f38146ef08706e20030b6aa96c","tarball":"http://registry-npm.ywwl.com/estree-to-babel/download/estree-to-babel-10.3.0.tgz","fileCount":20,"integrity":"sha512-NZIkqCHkK+dPVF/1KpLuMIJ5x2b2LG5WH3/1nxzOQ0p5Dgq38TkYvWPbBrMvuQMCF8Job4tsdXdkzgWcelFfcQ==","signatures":[{"sig":"MEQCIENSNxHCPAVAo4AbEzvVOoyrIyTDW0//Ri8CDMrs1GRNAiAFUElqUf6tnRG5fP7tSsltCzl1h/hGhF8UsGFZjQrThQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":26791,"size":7866,"noattachment":false,"key":"/estree-to-babel/-/estree-to-babel-10.3.0.tgz"},"main":"lib/estree-to-babel.js","type":"commonjs","types":"./lib/estree-to-babel.d.ts","engines":{"node":">=18"},"gitHead":"9e35e1cfa981a167a047879c25b8baef33873db7","scripts":{"lint":"madrun lint","test":"madrun test","report":"madrun report","fixture":"madrun fixture","coverage":"madrun coverage","fix:lint":"madrun fix:lint","test:dts":"madrun test:dts","fresh:lint":"madrun fresh:lint","lint:fresh":"madrun lint:fresh","watch:test":"madrun watch:test"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"repository":{"url":"git+https://github.com/coderaiser/estree-to-babel.git","type":"git"},"_npmVersion":"10.9.0","description":"convert estree ast to babel","directories":{},"_nodeVersion":"22.13.1","dependencies":{"@putout/babel":"^3.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.1.2","acorn":"^8.0.1","eslint":"^9.8.0","espree":"^10.0.1","madrun":"^10.0.0","putout":"^37.13.0","meriyah":"^6.0.2","nodemon":"^3.0.1","check-dts":"^0.8.0","supertape":"^10.1.0","typescript":"^5.1.3","acorn-stage3":"^4.0.0","eslint-plugin-putout":"^23.1.0","estree-util-attach-comments":"^3.0.0","@typescript-eslint/typescript-estree":"^8.11.0"},"_npmOperationalInternal":{"tmp":"tmp/estree-to-babel_10.3.0_1737987928285_0.21306699233321336","host":"s3://npm-registry-packages-npm-production"},"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&longCache=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&service=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}) => 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\nconst cherow = require('cherow');\nconst toBabel = require('estree-to-babel');\nconst traverse = require('@babel/traverse').default;\n\nconst options = {\n    convertParens: false,\n};\n\nconst ast = toBabel(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","publish_time":1737987928504,"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"_cnpm_publish_time":1737987928504,"dist-tags":{"latest":"12.0.1"}}