esast-util-from-estree
Advanced tools
Comparing version 1.0.0 to 1.1.0
26
index.js
@@ -0,1 +1,10 @@ | ||
/** | ||
* @typedef {import('unist').Node} UnistNode | ||
* @typedef {import('estree-jsx').Node} EstreeNode | ||
* @typedef {import('estree-util-visit').Visitor} Visitor | ||
* | ||
* @typedef Options | ||
* @property {boolean} [dirty=false] | ||
*/ | ||
import {positionFromEstree} from 'unist-util-position-from-estree' | ||
@@ -6,3 +15,9 @@ import {visit} from 'estree-util-visit' | ||
/** | ||
* @param {EstreeNode} estree | ||
* @param {Options} [options] | ||
* @returns {UnistNode} | ||
*/ | ||
export function fromEstree(estree, options = {}) { | ||
/** @type {UnistNode} */ | ||
var tail | ||
@@ -14,11 +29,22 @@ | ||
/** | ||
* @type {Visitor} | ||
* @param {EstreeNode} node | ||
*/ | ||
// eslint-disable-next-line complexity | ||
function onleave(node, field, index, parents) { | ||
var parent = parents[parents.length - 1] | ||
/** @type {EstreeNode} */ | ||
var context = index === null ? parent : parent[field] | ||
/** @type {string|number} */ | ||
var prop = index === null ? field : index | ||
/** @type {UnistNode} */ | ||
var copy = {} | ||
/** @type {string} */ | ||
var key | ||
/** @type {RegExpMatchArray} */ | ||
var match | ||
/** @type {number} */ | ||
var code | ||
/** @type {unknown} */ | ||
var value | ||
@@ -25,0 +51,0 @@ |
{ | ||
"name": "esast-util-from-estree", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "esast utility to transform from estree", | ||
@@ -30,4 +30,5 @@ "license": "MIT", | ||
], | ||
"sideEffects": false, | ||
"type": "module", | ||
"module": "./index.js", | ||
"main": "index.js", | ||
"files": [ | ||
@@ -37,2 +38,3 @@ "index.js" | ||
"dependencies": { | ||
"@types/estree-jsx": "^0.0.1", | ||
"estree-util-visit": "^1.0.0", | ||
@@ -42,16 +44,21 @@ "unist-util-position-from-estree": "^1.0.0" | ||
"devDependencies": { | ||
"@types/tape": "^4.0.0", | ||
"acorn": "^8.0.0", | ||
"c8": "^7.5.0", | ||
"nyc": "^15.0.0", | ||
"c8": "^7.0.0", | ||
"prettier": "^2.0.0", | ||
"remark-cli": "^9.0.0", | ||
"remark-preset-wooorm": "^8.0.0", | ||
"rimraf": "^3.0.0", | ||
"tape": "^5.0.0", | ||
"xo": "^0.37.0" | ||
"type-coverage": "^2.0.0", | ||
"typescript": "^4.0.0", | ||
"xo": "^0.39.0" | ||
}, | ||
"scripts": { | ||
"prepack": "npm run build && npm run format", | ||
"build": "rimraf \"*.d.ts\" && tsc && type-coverage", | ||
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix", | ||
"test-api": "node test", | ||
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node --experimental-modules test.js", | ||
"test": "npm run format && npm run test-coverage" | ||
"test-api": "node test.js", | ||
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js", | ||
"test": "npm run build && npm run format && npm run test-coverage" | ||
}, | ||
@@ -68,3 +75,2 @@ "prettier": { | ||
"prettier": true, | ||
"ignores": [], | ||
"rules": { | ||
@@ -79,3 +85,8 @@ "no-var": "off", | ||
] | ||
}, | ||
"typeCoverage": { | ||
"atLeast": 100, | ||
"detail": true, | ||
"strict": true | ||
} | ||
} |
@@ -20,2 +20,5 @@ # esast-util-from-estree | ||
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c): | ||
Node 12+ is needed to use it and it must be `import`ed instead of `require`d. | ||
[npm][]: | ||
@@ -27,4 +30,2 @@ | ||
Note that this package is ESM only: it must be imported instead of required. | ||
## Use | ||
@@ -78,4 +79,3 @@ | ||
`esast-util-from-estree` exports the following identifiers: | ||
[`fromEstree`](#fromestreeestree-options). | ||
This package exports the following identifiers: `fromEstree`. | ||
There is no default export. | ||
@@ -82,0 +82,0 @@ |
9263
84
3
11
+ Added@types/estree-jsx@^0.0.1
+ Added@types/estree-jsx@0.0.1(transitive)