`loc` instead `position` in node object?
tunnckoCore opened this issue · 7 comments
to follow esprima/acorn format?
{
"loc": {
"start": {
"line": 82,
"column": 0
},
"end": {
"line": 87,
"column": 3
}
}
worth considering, but I'm not sure how important that is, or if esprima/acorn are the model to follow. I'll make it a feature request
I think with release of 0.5.0
we can close this, but only don't like that it is lineno
instead of line
, everything other is okey.
I rethink it and every parser (postcss, retext, remark, posthtml, postjson) except esprima/acorn
follows the
{
"position": {
"start": {
"line": 82,
"column": 0
},
"end": {
"line": 87,
"column": 3
}
}
style, not loc
.
I might change it in 0.6.0 when the lexer is added
we can close this
done, thanks
Okey, great. And one more note, why not node.value
instead of node.val
?
no real reason. the parser/renderer was originally based on one of TJ's libs CSS (mentioned on the readme) and it used val
.
Also, this might seem strange, but I tend to use short variable names specifically for variables that are repeated a bunch of times in a file - since in those cases the variable should be easily identifiable, and when a variable like that is long it makes it harder to scan for "statistically improbable code". I like to be able to see what's important at a glance
Thought for that and I'm agree with you. Everyone will understand what val
is, but I think it's better to be value
because ASTs are more for humans. Worth nothing, don't know.
edit: Also it would be cool to follow a few AST specs that @wooorm created and this will allow users to use some of already existing AST utils like unist-util-*
.