Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions packages/espree/lib/espree.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,35 +181,6 @@ export default () => Parser => {
program.tokens = extra.tokens;
}

/*
* Adjust opening and closing position of program to match Esprima.
* Acorn always starts programs at range 0 whereas Esprima starts at the
* first AST node's start (the only real difference is when there's leading
* whitespace or leading comments). Acorn also counts trailing whitespace
* as part of the program whereas Esprima only counts up to the last token.
*/
if (program.body.length) {
const [firstNode] = program.body;

if (program.range) {
program.range[0] = firstNode.range[0];
}
if (program.loc) {
program.loc.start = firstNode.loc.start;
}
program.start = firstNode.start;
}
if (extra.lastToken) {
if (program.range) {
program.range[1] = extra.lastToken.range[1];
}
if (program.loc) {
program.loc.end = extra.lastToken.loc.end;
}
program.end = extra.lastToken.end;
}


/*
* https://github.com/eslint/espree/issues/349
* Ensure that template elements have correct range information.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export default {
"column": 0
},
"end": {
"line": 1,
"column": 12
"line": 2,
"column": 0
}
},
"range": [
0,
12
13
],
"body": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export default {
"column": 0
},
"end": {
"line": 1,
"column": 7
"line": 2,
"column": 0
}
},
"range": [
0,
7
8
],
"body": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export default {
"column": 0
},
"end": {
"line": 1,
"column": 12
"line": 2,
"column": 0
}
},
"range": [
0,
12
13
],
"body": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export default {
"column": 0
},
"end": {
"line": 1,
"column": 61
"line": 2,
"column": 0
}
},
"range": [
0,
61
62
],
"body": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export default {
"column":0
},
"end":{
"line":1,
"column":12
"line":2,
"column":0
}
},
"range":[
0,
12
13
],
"body":[
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export default {
"column":0
},
"end":{
"line":1,
"column":12
"line":2,
"column":0
}
},
"range":[
0,
12
13
],
"body":[
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export default {
"column": 0
},
"end": {
"line": 14,
"column": 29
"line": 15,
"column": 0
}
},
"range": [
0,
292
293
],
"body": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export default {
"column": 0
},
"end": {
"line": 1,
"column": 19
"line": 2,
"column": 0
}
},
"range": [
0,
19
20
],
"body": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export default {
"column": 0
},
"end": {
"line": 1,
"column": 22
"line": 2,
"column": 0
}
},
"range": [
0,
22
23
],
"body": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export default {
"column": 0
},
"end": {
"line": 2,
"column": 1
"line": 3,
"column": 0
}
},
"range": [
0,
11
12
],
"body": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export default {
"column": 0
},
"end": {
"line": 2,
"column": 1
"line": 3,
"column": 0
}
},
"range": [
0,
11
12
],
"body": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export default {
"column": 0
},
"end": {
"line": 1,
"column": 15
"line": 2,
"column": 0
}
},
"range": [
0,
15
16
],
"body": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export default {
"column": 0
},
"end": {
"line": 5,
"column": 1
"line": 6,
"column": 0
}
},
"range": [
0,
37
38
],
"body": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export default {
"column": 0
},
"end": {
"line": 1,
"column": 7
"line": 2,
"column": 0
}
},
"range": [
0,
7
8
],
"body": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export default {
"column": 0
},
"end": {
"line": 1,
"column": 2
"line": 2,
"column": 0
}
},
"range": [
0,
2
3
],
"body": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export default {
"column": 0
},
"end": {
"line": 1,
"column": 5
"line": 2,
"column": 0
}
},
"range": [
0,
5
6
],
"body": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export default {
"column": 0
},
"end": {
"line": 1,
"column": 6
"line": 2,
"column": 0
}
},
"range": [
0,
6
7
],
"body": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export default {
"column": 0
},
"end": {
"line": 3,
"column": 1
"line": 4,
"column": 0
}
},
"range": [
0,
62
63
],
"body": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export default {
"column": 0
},
"end": {
"line": 1,
"column": 14
"line": 2,
"column": 0
}
},
"range": [
0,
14
15
],
"body": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export default {
"column": 0
},
"end": {
"line": 1,
"column": 20
"line": 2,
"column": 0
}
},
"range": [
0,
20
21
],
"body": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export default {
"column": 0
},
"end": {
"line": 1,
"column": 25
"line": 2,
"column": 0
}
},
"range": [
0,
25
26
],
"body": [
{
Expand Down
Loading
Loading