Skip to content

Commit d7ce4f8

Browse files
authored
Fixed wrong end location of Program node. (#16)
1 parent 30f61e0 commit d7ce4f8

29 files changed

+156
-150
lines changed

lib/parser/json-eslint-parser.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ export function parseForESLint(
5858
return throwUnexpectedTokenError(",", last)
5959
}
6060

61+
ast.range[1] = statement.range![1] = last.range[1]
62+
ast.loc.end.line = statement.loc!.end.line = last.loc.end.line
63+
ast.loc.end.column = statement.loc!.end.column = last.loc.end.column
6164
ast.body = [statement]
6265
statement.expression = expression
6366

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-jsonc",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
44
"description": "ESLint plugin for JSON, JSONC and JSON5 files.",
55
"main": "dist/index.js",
66
"typescript": {
@@ -58,7 +58,7 @@
5858
},
5959
"homepage": "https://ota-meshi.github.io/eslint-plugin-jsonc/",
6060
"peerDependencies": {
61-
"eslint": ">=6.0.0"
61+
"eslint": "^5.0.0 || >=6.0.0"
6262
},
6363
"devDependencies": {
6464
"@mysticatea/eslint-plugin": "^13.0.0",

tests/fixtures/parser/ast/array-01-output.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,16 @@
138138
},
139139
"range": [
140140
0,
141-
15
141+
13
142142
],
143143
"loc": {
144144
"start": {
145145
"line": 1,
146146
"column": 0
147147
},
148148
"end": {
149-
"line": 2,
150-
"column": 1
149+
"line": 1,
150+
"column": 13
151151
}
152152
}
153153
}
@@ -391,16 +391,16 @@
391391
],
392392
"range": [
393393
0,
394-
15
394+
13
395395
],
396396
"loc": {
397397
"start": {
398398
"line": 1,
399399
"column": 0
400400
},
401401
"end": {
402-
"line": 2,
403-
"column": 1
402+
"line": 1,
403+
"column": 13
404404
}
405405
}
406406
}

tests/fixtures/parser/ast/array-02-output.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,16 @@
138138
},
139139
"range": [
140140
0,
141-
17
141+
15
142142
],
143143
"loc": {
144144
"start": {
145145
"line": 1,
146146
"column": 0
147147
},
148148
"end": {
149-
"line": 2,
150-
"column": 1
149+
"line": 1,
150+
"column": 15
151151
}
152152
}
153153
}
@@ -427,16 +427,16 @@
427427
],
428428
"range": [
429429
0,
430-
17
430+
15
431431
],
432432
"loc": {
433433
"start": {
434434
"line": 1,
435435
"column": 0
436436
},
437437
"end": {
438-
"line": 2,
439-
"column": 1
438+
"line": 1,
439+
"column": 15
440440
}
441441
}
442442
}

tests/fixtures/parser/ast/array-empty-slots-01-output.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@
4444
},
4545
"range": [
4646
0,
47-
8
47+
6
4848
],
4949
"loc": {
5050
"start": {
5151
"line": 1,
5252
"column": 0
5353
},
5454
"end": {
55-
"line": 2,
56-
"column": 1
55+
"line": 1,
56+
"column": 6
5757
}
5858
}
5959
}
@@ -135,16 +135,16 @@
135135
],
136136
"range": [
137137
0,
138-
8
138+
6
139139
],
140140
"loc": {
141141
"start": {
142142
"line": 1,
143143
"column": 0
144144
},
145145
"end": {
146-
"line": 2,
147-
"column": 1
146+
"line": 1,
147+
"column": 6
148148
}
149149
}
150150
}

tests/fixtures/parser/ast/array-empty-slots-02-output.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,16 @@
6363
},
6464
"range": [
6565
0,
66-
12
66+
10
6767
],
6868
"loc": {
6969
"start": {
7070
"line": 1,
7171
"column": 0
7272
},
7373
"end": {
74-
"line": 2,
75-
"column": 1
74+
"line": 1,
75+
"column": 10
7676
}
7777
}
7878
}
@@ -190,16 +190,16 @@
190190
],
191191
"range": [
192192
0,
193-
12
193+
10
194194
],
195195
"loc": {
196196
"start": {
197197
"line": 1,
198198
"column": 0
199199
},
200200
"end": {
201-
"line": 2,
202-
"column": 1
201+
"line": 1,
202+
"column": 10
203203
}
204204
}
205205
}

tests/fixtures/parser/ast/bingint-01-output.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,16 @@
8484
},
8585
"range": [
8686
0,
87-
12
87+
10
8888
],
8989
"loc": {
9090
"start": {
9191
"line": 1,
9292
"column": 0
9393
},
9494
"end": {
95-
"line": 2,
96-
"column": 1
95+
"line": 1,
96+
"column": 10
9797
}
9898
}
9999
}
@@ -193,16 +193,16 @@
193193
],
194194
"range": [
195195
0,
196-
12
196+
10
197197
],
198198
"loc": {
199199
"start": {
200200
"line": 1,
201201
"column": 0
202202
},
203203
"end": {
204-
"line": 2,
205-
"column": 1
204+
"line": 1,
205+
"column": 10
206206
}
207207
}
208208
}

tests/fixtures/parser/ast/infinity-01-output.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,16 @@
116116
},
117117
"range": [
118118
0,
119-
34
119+
32
120120
],
121121
"loc": {
122122
"start": {
123123
"line": 1,
124124
"column": 0
125125
},
126126
"end": {
127-
"line": 2,
128-
"column": 1
127+
"line": 1,
128+
"column": 32
129129
}
130130
}
131131
}
@@ -297,16 +297,16 @@
297297
],
298298
"range": [
299299
0,
300-
34
300+
32
301301
],
302302
"loc": {
303303
"start": {
304304
"line": 1,
305305
"column": 0
306306
},
307307
"end": {
308-
"line": 2,
309-
"column": 1
308+
"line": 1,
309+
"column": 32
310310
}
311311
}
312312
}

tests/fixtures/parser/ast/infinity-02-output.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,15 @@
233233
},
234234
"range": [
235235
0,
236-
56
236+
54
237237
],
238238
"loc": {
239239
"start": {
240240
"line": 1,
241241
"column": 0
242242
},
243243
"end": {
244-
"line": 6,
244+
"line": 5,
245245
"column": 1
246246
}
247247
}
@@ -522,15 +522,15 @@
522522
],
523523
"range": [
524524
0,
525-
56
525+
54
526526
],
527527
"loc": {
528528
"start": {
529529
"line": 1,
530530
"column": 0
531531
},
532532
"end": {
533-
"line": 6,
533+
"line": 5,
534534
"column": 1
535535
}
536536
}

tests/fixtures/parser/ast/infinity-03-output.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@
2323
},
2424
"range": [
2525
0,
26-
10
26+
8
2727
],
2828
"loc": {
2929
"start": {
3030
"line": 1,
3131
"column": 0
3232
},
3333
"end": {
34-
"line": 2,
35-
"column": 1
34+
"line": 1,
35+
"column": 8
3636
}
3737
}
3838
}
@@ -60,16 +60,16 @@
6060
],
6161
"range": [
6262
0,
63-
10
63+
8
6464
],
6565
"loc": {
6666
"start": {
6767
"line": 1,
6868
"column": 0
6969
},
7070
"end": {
71-
"line": 2,
72-
"column": 1
71+
"line": 1,
72+
"column": 8
7373
}
7474
}
7575
}

0 commit comments

Comments
 (0)