All Projects → coderaiser → estree-to-babel

coderaiser / estree-to-babel

Licence: MIT license
convert estree ast to babel

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects
HCL
1544 projects

Projects that are alternatives of or similar to estree-to-babel

parse-function
(!! moved to tunnckoCore/opensource multi-package repository !!) 🔱 Parse a function into an object using espree, acorn or babylon parsers. Extensible through Smart Plugins.
Stars: ✭ 37 (+60.87%)
Mutual labels:  ast, espree
astravel
👟 Tiny and fast ESTree-compliant AST walker and modifier.
Stars: ✭ 38 (+65.22%)
Mutual labels:  ast, estree
eval-estree-expression
Safely evaluate JavaScript (estree) expressions, sync and async.
Stars: ✭ 22 (-4.35%)
Mutual labels:  ast, estree
esvalid
confirm that a SpiderMonkey format AST represents an ECMAScript program
Stars: ✭ 24 (+4.35%)
Mutual labels:  ast, estree
kataw
An 100% spec compliant ES2022 JavaScript toolchain
Stars: ✭ 303 (+1217.39%)
Mutual labels:  ast, estree
Babylon
PSA: moved into babel/babel as @babel/parser -->
Stars: ✭ 1,692 (+7256.52%)
Mutual labels:  ast, estree
Estree
The ESTree Spec
Stars: ✭ 3,867 (+16713.04%)
Mutual labels:  ast, estree
Escodegen
ECMAScript code generator
Stars: ✭ 2,328 (+10021.74%)
Mutual labels:  ast, estree
pgsql-ast-parser
Yet another simple Postgres SQL parser
Stars: ✭ 152 (+560.87%)
Mutual labels:  ast
konan
find all require/import calls by walking the AST
Stars: ✭ 48 (+108.7%)
Mutual labels:  ast
abstract-syntax-tree
A library for working with abstract syntax trees.
Stars: ✭ 77 (+234.78%)
Mutual labels:  ast
tree-hugger
A light-weight, extendable, high level, universal code parser built on top of tree-sitter
Stars: ✭ 96 (+317.39%)
Mutual labels:  ast
vscode-blockman
VSCode extension to highlight nested code blocks
Stars: ✭ 233 (+913.04%)
Mutual labels:  ast
py2many
Transpiler of Python to many other languages
Stars: ✭ 420 (+1726.09%)
Mutual labels:  ast
performance-decorator
🏇User behavior & Function execution tracking solution - 大型前端项目的用户行为跟踪,函数调用链分析,断点调试共享化和复用化实践
Stars: ✭ 39 (+69.57%)
Mutual labels:  ast
clickhouse-ast-parser
AST parser and visitor for ClickHouse SQL
Stars: ✭ 60 (+160.87%)
Mutual labels:  ast
babel-plugin-detective
Babel plugin that scans the AST for require calls and import statements
Stars: ✭ 26 (+13.04%)
Mutual labels:  ast
rector-nette
Rector upgrades rules for Nette
Stars: ✭ 16 (-30.43%)
Mutual labels:  ast
about-Vue
📔 Vue 源码的探讨和学习
Stars: ✭ 56 (+143.48%)
Mutual labels:  ast
human-parser-generator
A straightforward recursive descent Parser Generator with a focus on "human" code generation and ease of use.
Stars: ✭ 27 (+17.39%)
Mutual labels:  ast

Estree-to-babel NPM version Build Status Coverage Status

Convert ESTree-compatible JavaScript AST to Babel AST.

To use parsers like:

With babel tools like:

The thing is @babel/parser has a little differences with estree standard:

  • Property of ObjectExpression and ObjectPattern called ObjectProperty;
  • FunctionExpression of a Property located in ObjectMethod node;
  • File node;
  • StringLiteral, NumericLiteral, NullLiteral, RegExpLiteral, BooleanLiteral instead of Literal;
  • ClassMethod instead of MethodDefinition;
  • ClassPrivateMethod;
  • ClassPrivateName stores name as Identifier in id field;
  • ClassPrivateProperty instead of FieldDefinition;
  • CallExpression instead of ImportExpression;
  • OptionalMemberExpression and OptionalCallExpression instead of ChainExpression;
  • ImportDeclaration and ExportNamedDeclaration has assertions;
  • etc...

Also @babel/parser has differences with typescript-estree:

  • TSExpressionWithTypeArguments instead of TSClassImplements;
  • ClassPrivateProperty instead of PropertyDefinition when key.type=PrivateName;
  • ClasseProperty instead of PropertyDefinition when key.type=Identifier;
  • PrivateName instead of PrivateIdentifier;
  • TSInterfaceHeritage instead of TSExpressionWithTypeArguments;
  • TSQualifiedName instead of MemberExpression in TSInterfaceHeritage;
  • TSDeclaredMethod with abstract=true instead of TSAbstractMethodDefinition;
  • etc...

estree-to-babel aims to smooth this differences.

Install

npm i estree-to-babel

Example

const cherow = require('cherow');
const toBabel = require('estree-to-babel');
const traverse = require('@babel/traverse').default;

const ast = toBabel(cherow.parse(`
    const f = ({a}) => a;
`));

traverse({
    ObjectProperty(path) {
        console.log(path.value.name);
        // output
        'a';
    },
});

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].