{"name":"estree-to-babel","version":"12.0.1","type":"module","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":"^5.1.2"},"keywords":["ast","convert","estree","babel","espree"],"devDependencies":{"@typescript-eslint/typescript-estree":"^8.11.0","acorn":"^8.0.1","acorn-stage3":"^4.0.0","check-dts":"^0.9.0","eslint":"^10.0.2","eslint-plugin-putout":"^31.0.2","espree":"^11.0.0","estree-util-attach-comments":"^3.0.0","json-with-bigint":"^3.4.4","madrun":"^13.0.0","meriyah":"^7.0.0","nodemon":"^3.0.1","putout":"^42.0.25","superc8":"^12.2.4","supertape":"^12.0.0","typescript":"^5.1.3"},"license":"MIT","engines":{"node":">=22"},"publishConfig":{"access":"public"},"_id":"estree-to-babel@12.0.1","gitHead":"2099e1961f4c4c129e1437744f7b0d646ed5aee2","types":"./lib/estree-to-babel.d.ts","bugs":{"url":"https://github.com/coderaiser/estree-to-babel/issues"},"_nodeVersion":"24.14.0","_npmVersion":"11.4.2","dist":{"integrity":"sha512-kSaHctCwRcmG46abEVWJf8pUGayFFHDGPBQN3k7XmaERyBUtOR9uFFmxF4Gi8QEMUbh2UX+WZJ/fBbahq/OC8A==","shasum":"0dbfb3da51b6a5e5973cf09ad5049b0b8b32c05b","tarball":"http://registry-npm.ywwl.com/estree-to-babel/download/estree-to-babel-12.0.1.tgz","fileCount":21,"unpackedSize":29654,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCNP8nBdrptSr4CKnpTqcRaV4hYJeShNpvooEb91O5cogIgPtVe2KoMz1AjqE9fgmqDvWnIPT1mdVm78+vXXVMkwwc="}],"size":8631,"noattachment":false,"key":"/estree-to-babel/-/estree-to-babel-12.0.1.tgz"},"_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"directories":{},"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/estree-to-babel_12.0.1_1772623795023_0.8607974587595251"},"_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\nimport {parse} from 'cherow';\nimport {estreeToBabel} from 'estree-to-babel';\nimport {traverse} from '@babel/traverse';\n\nconst ast = estreeToBabel(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\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","publish_time":1772623795167,"_cnpm_publish_time":1772623795167,"dist-tags":{"latest":"12.0.1"}}