Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
unist-util-position-from-estree
Advanced tools
unist utility to get a position from an estree node.
This package is ESM only:
Node 12+ is needed to use it and it must be import
ed instead of require
d.
npm:
npm install unist-util-position-from-estree
import {parse} from 'acorn'
import {positionFromEstree} from 'unist-util-position-from-estree'
// Make acorn support line/column.
const node = parse('function x() { console.log(1) }', {
ecmaVersion: 2020,
locations: true
})
console.log(positionFromEstree(node)) // `Program`
console.log(positionFromEstree(node.body[0].id)) // `x`
console.log(positionFromEstree(node.body[0].body.body[0].expression)) // Call
Yields:
{
start: {line: 1, column: 1, offset: 0},
end: {line: 1, column: 32, offset: 31}
}
{
start: {line: 1, column: 10, offset: 9},
end: {line: 1, column: 11, offset: 10}
}
{
start: {line: 1, column: 16, offset: 15},
end: {line: 1, column: 30, offset: 29}
}
This package exports the following identifiers: positionFromEstree
.
There is no default export.
positionFromEstree(node)
Given a node
, returns a position
.
See contributing.md
in syntax-tree/.github
for ways to get
started.
See support.md
for ways to get help.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.
FAQs
unist utility to get a position from an estree node
The npm package unist-util-position-from-estree receives a total of 1,310,271 weekly downloads. As such, unist-util-position-from-estree popularity was classified as popular.
We found that unist-util-position-from-estree demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.