estree-to-babel
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -6,3 +6,4 @@ 'use strict'; | ||
isObjectExpression, | ||
isLiteral | ||
isLiteral, | ||
classMethod, | ||
} = require('@babel/types'); | ||
@@ -15,2 +16,4 @@ | ||
const {assign} = Object; | ||
module.exports = (node) => { | ||
@@ -41,3 +44,6 @@ const { | ||
if (type === 'Property') | ||
return setProperty(node); | ||
return setObjectProperty(node); | ||
if (type === 'MethodDefinition') | ||
return setClassMethod(path); | ||
}, | ||
@@ -49,3 +55,34 @@ }); | ||
function setProperty(node) { | ||
function setClassMethod(path) { | ||
const {node} = path; | ||
const { | ||
key, | ||
kind, | ||
computed, | ||
} = node; | ||
const { | ||
body, | ||
params, | ||
expression, | ||
generator, | ||
} = node.value; | ||
path.replaceWith(classMethod( | ||
kind, | ||
key, | ||
params, | ||
body, | ||
computed, | ||
node.static, | ||
) | ||
); | ||
assign(path.node, { | ||
expression, | ||
generator, | ||
}); | ||
} | ||
function setObjectProperty(node) { | ||
node.type = 'ObjectProperty'; | ||
@@ -52,0 +89,0 @@ } |
{ | ||
"name": "estree-to-babel", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)", | ||
@@ -18,2 +18,4 @@ "description": "convert estree ast to babel", | ||
"lint": "eslint lib test --ignore-pattern test/fixture", | ||
"putout:fix": "redrun putout -- --fix", | ||
"putout": "putout lib test", | ||
"coverage": "nyc npm test", | ||
@@ -41,2 +43,3 @@ "report": "nyc report --reporter=text-lcov | coveralls" | ||
"nyc": "^13.0.1", | ||
"putout": "^3.0.0", | ||
"redrun": "^7.0.2", | ||
@@ -43,0 +46,0 @@ "tape": "^4.8.0", |
@@ -30,3 +30,4 @@ # Estree-to-babel [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL] | ||
- `File` node; | ||
- `StringLiteral`, `NumericLiteral` instead of `Literal` | ||
- `StringLiteral`, `NumericLiteral` instead of `Literal`; | ||
- `ClassMethod` instead of `MethodDefinition`; | ||
- etc... | ||
@@ -33,0 +34,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7636
102
66
11