syntax-tree / estree-util-attach-comments Goto Github PK
View Code? Open in Web Editor NEWutility to attach comments to estree nodes
License: MIT License
utility to attach comments to estree nodes
License: MIT License
There is a bug in the plugin which results in generating the wrong node.
The input code
/**
* Draws lines on the corresponding layer.
* @param {number} firstRow the first row to render
*/
function drawLines(
firstRow,
) {
console.log("x")
}
Gives the following with Espree 4's attach comment (notice the leadingComments property in body)
Node {
type: 'Program',
start: 0,
end: 170,
range: [ 108, 168 ],
body: [
Node {
type: 'FunctionDeclaration',
start: 108,
end: 168,
range: [Array],
id: [Node],
expression: false,
generator: false,
async: false,
params: [Array],
body: [Node],
leadingComments: [Array]
}
],
sourceType: 'module',
comments: [
{
type: 'Block',
value: '*\r\n' +
' * Draws lines on the corresponding layer.\r\n' +
' * @param {number} firstRow the first row to render\r\n' +
' ',
start: 0,
end: 106,
range: [Array]
}
]
}
But using Espree 7 and this package we get the following. estree-util-attach-comments ignores leading
property
type: 'Program',
start: 0,
end: 170,
body: [
Node {
type: 'FunctionDeclaration',
start: 108,
end: 168,
id: [Node],
expression: false,
generator: false,
async: false,
params: [Array],
body: [Node]
}
],
sourceType: 'module',
comments: [
{
type: 'Block',
value: '*\r\n' +
' * Draws lines on the corresponding layer.\r\n' +
' * @param {number} firstRow the first row to render\r\n' +
' ',
start: 0,
end: 106,
range: [Array],
leading: true,
trailing: false
}
]
}
The package doesn't include a CJS output. Could you add that?
Espree doesn't have onComment
like acorn
. How can I make this work with Espree?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.