-
-
Notifications
You must be signed in to change notification settings - Fork 214
Closed
Labels
Description
require('@babel/parser').parse(' /**/ a /**/ ', {ranges: true}).program
// {start:0, end: 22, range: [0, 22]}
require('acorn').parse(' /**/ a /**/ ', {ranges: true})
// {start:0, end: 22, range: [0, 22]}
require('meriyah').parse(' /**/ a /**/ ', {ranges: true})
// {start:0, end: 22, range: [0, 22]}
require('@typescript-eslint/typescript-estree').parse(' /**/ a /**/ ', {range: true})
// {range: [10, 22]}
(I think they are starting from 10
only to align with espree
)
require('espree').parse(' /**/ a /**/ ', {range: true, loc: true})
// {range: [10, 11], start: 0, end: 22} ({start: 10, end: 11} on master branch)
It doesn't make sense at all, if there is no statement, just comments and whitespace, what should it be?(currently we count from 0
)
Image this, I have a function to check comment is inside node, isInsideNode(comment, node)
, If only comments, it's true
, if I wrote a letter or number anywhere, it's false
.