{"name":"estree-to-babel","version":"10.5.0","type":"commonjs","author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"description":"convert estree ast to babel","homepage":"http://github.com/coderaiser/estree-to-babel","main":"lib/estree-to-babel.js","repository":{"type":"git","url":"git+https://github.com/coderaiser/estree-to-babel.git"},"scripts":{"test":"madrun test","test:dts":"madrun test:dts","watch:test":"madrun watch:test","lint":"madrun lint","fresh:lint":"madrun fresh:lint","lint:fresh":"madrun lint:fresh","fix:lint":"madrun fix:lint","coverage":"madrun coverage","report":"madrun report","fixture":"madrun fixture"},"dependencies":{"@putout/babel":"^3.0.0"},"keywords":["ast","convert","estree","babel","espree"],"devDependencies":{"@typescript-eslint/typescript-estree":"^8.11.0","acorn":"^8.0.1","acorn-stage3":"^4.0.0","c8":"^10.1.2","check-dts":"^0.8.0","eslint":"^9.8.0","eslint-plugin-putout":"^24.0.2","espree":"^10.0.1","estree-util-attach-comments":"^3.0.0","madrun":"^10.0.0","meriyah":"^6.0.2","nodemon":"^3.0.1","putout":"^38.0.10","supertape":"^10.1.0","typescript":"^5.1.3"},"license":"MIT","engines":{"node":">=18"},"publishConfig":{"access":"public"},"_id":"estree-to-babel@10.5.0","gitHead":"97279aa0c2964ca5f4e0bd15e010082de81bc153","types":"./lib/estree-to-babel.d.ts","bugs":{"url":"https://github.com/coderaiser/estree-to-babel/issues"},"_nodeVersion":"22.13.1","_npmVersion":"10.9.0","dist":{"integrity":"sha512-NUBZPOopJNJFGHQg3kODfNWOJW7KgOQl1H2co348IsZ3z58MokyiQFsADFbGf/3Z/QumGzkvybe3y9rS84VTJg==","shasum":"e4ec812010038ff35a2f717883b325e65f3183a5","tarball":"http://registry-npm.ywwl.com/estree-to-babel/download/estree-to-babel-10.5.0.tgz","fileCount":21,"unpackedSize":28299,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIDAiyMSdWawKmLbtq96Hp3S2819Y/FJ4SKpQE2wa7J7oAiEAkFOidWpRWftfrOobmLtPk2T5x6Kn47UrIn7zIQN1bMo="}],"size":8201,"noattachment":false,"key":"/estree-to-babel/-/estree-to-babel-10.5.0.tgz"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/estree-to-babel_10.5.0_1739118437153_0.1344647214481116"},"_hasShrinkwrap":false,"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":1739118437422,"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"_cnpm_publish_time":1739118437422,"dist-tags":{"latest":"12.0.1"}}