Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit 67971de

Browse files
authored
Fix: Include newlines at the end of source in AST (fixes #352) (#353)
1 parent 8406209 commit 67971de

File tree

6 files changed

+630
-631
lines changed

6 files changed

+630
-631
lines changed

lib/convert.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,7 @@ module.exports = function convert(config) {
331331
}
332332
});
333333

334-
// fix end location
335-
result.range[1] = node.endOfFileToken.pos;
334+
result.range[1] = node.endOfFileToken.end;
336335
result.loc = nodeUtils.getLocFor(node.getStart(), result.range[1], ast);
337336
break;
338337

tests/lib/__snapshots__/basics.js.snap

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ Object {
9696
],
9797
"loc": Object {
9898
"end": Object {
99-
"column": 15,
100-
"line": 1,
99+
"column": 0,
100+
"line": 2,
101101
},
102102
"start": Object {
103103
"column": 0,
@@ -106,7 +106,7 @@ Object {
106106
},
107107
"range": Array [
108108
0,
109-
15,
109+
16,
110110
],
111111
"sourceType": "script",
112112
"tokens": Array [
@@ -501,8 +501,8 @@ Object {
501501
],
502502
"loc": Object {
503503
"end": Object {
504-
"column": 16,
505-
"line": 6,
504+
"column": 0,
505+
"line": 7,
506506
},
507507
"start": Object {
508508
"column": 0,
@@ -511,7 +511,7 @@ Object {
511511
},
512512
"range": Array [
513513
0,
514-
58,
514+
59,
515515
],
516516
"sourceType": "script",
517517
"tokens": Array [
@@ -1181,8 +1181,8 @@ Object {
11811181
],
11821182
"loc": Object {
11831183
"end": Object {
1184-
"column": 1,
1185-
"line": 9,
1184+
"column": 0,
1185+
"line": 10,
11861186
},
11871187
"start": Object {
11881188
"column": 0,
@@ -1191,7 +1191,7 @@ Object {
11911191
},
11921192
"range": Array [
11931193
0,
1194-
59,
1194+
60,
11951195
],
11961196
"sourceType": "script",
11971197
"tokens": Array [
@@ -1716,8 +1716,8 @@ Object {
17161716
],
17171717
"loc": Object {
17181718
"end": Object {
1719-
"column": 14,
1720-
"line": 1,
1719+
"column": 0,
1720+
"line": 2,
17211721
},
17221722
"start": Object {
17231723
"column": 0,
@@ -1726,7 +1726,7 @@ Object {
17261726
},
17271727
"range": Array [
17281728
0,
1729-
14,
1729+
15,
17301730
],
17311731
"sourceType": "script",
17321732
"tokens": Array [
@@ -2219,8 +2219,8 @@ Object {
22192219
],
22202220
"loc": Object {
22212221
"end": Object {
2222-
"column": 12,
2223-
"line": 1,
2222+
"column": 0,
2223+
"line": 2,
22242224
},
22252225
"start": Object {
22262226
"column": 0,
@@ -2229,7 +2229,7 @@ Object {
22292229
},
22302230
"range": Array [
22312231
0,
2232-
12,
2232+
13,
22332233
],
22342234
"sourceType": "script",
22352235
"tokens": Array [
@@ -2978,8 +2978,8 @@ Object {
29782978
],
29792979
"loc": Object {
29802980
"end": Object {
2981-
"column": 8,
2982-
"line": 2,
2981+
"column": 0,
2982+
"line": 3,
29832983
},
29842984
"start": Object {
29852985
"column": 0,
@@ -2988,7 +2988,7 @@ Object {
29882988
},
29892989
"range": Array [
29902990
0,
2991-
16,
2991+
17,
29922992
],
29932993
"sourceType": "script",
29942994
"tokens": Array [

0 commit comments

Comments
 (0)