{"name":"estree-to-babel","version":"12.0.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@12.0.0","maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"homepage":"http://github.com/coderaiser/estree-to-babel","bugs":{"url":"https://github.com/coderaiser/estree-to-babel/issues"},"dist":{"shasum":"0cb3bf9a4f20675b09555c884719681f55d6ec06","tarball":"http://registry-npm.ywwl.com/estree-to-babel/download/estree-to-babel-12.0.0.tgz","fileCount":21,"integrity":"sha512-Vo5Wa1Dgkguoy6F0AKWbh5MUPi4nuc+KxBvD/xCwj4dNloZPK8fbfrfzqKhQT0BZrlLe2+AKZzHvNKAWi0wYjw==","signatures":[{"sig":"MEYCIQCBU/RgH6sKc8CIiB6947teOYFKFZGxjbyvXE1BwgebsAIhAJ8rYAKwMx++99dVZ59ANDq8ItJCXxr1rLGuWcRuxSPY","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":29334,"size":8530,"noattachment":false,"key":"/estree-to-babel/-/estree-to-babel-12.0.0.tgz"},"main":"lib/estree-to-babel.js","type":"module","types":"./lib/estree-to-babel.d.ts","engines":{"node":">=22"},"gitHead":"560ae47b1fff29e16fd8d10335b432aaaa9067f7","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":"11.2.0","description":"convert estree ast to babel","directories":{},"_nodeVersion":"24.12.0","dependencies":{"@putout/babel":"^5.1.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.1.2","acorn":"^8.0.1","eslint":"^9.8.0","espree":"^11.0.0","madrun":"^12.1.0","putout":"^41.6.1","meriyah":"^7.0.0","nodemon":"^3.0.1","check-dts":"^0.9.0","supertape":"^12.0.0","typescript":"^5.1.3","acorn-stage3":"^4.0.0","json-with-bigint":"^3.4.4","eslint-plugin-putout":"^29.3.0","estree-util-attach-comments":"^3.0.0","@typescript-eslint/typescript-estree":"^8.11.0"},"_npmOperationalInternal":{"tmp":"tmp/estree-to-babel_12.0.0_1767812158368_0.2475122899042128","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\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":1767812158505,"_cnpm_publish_time":1767812158505,"dist-tags":{"latest":"12.0.1"}}