Commit b46414f
committed
test: failing regression — program.comments is not sorted by range
ESLint's SourceCode builds both `tokensAndComments = sortedMerge(tokens,
comments)` and the token-store's `createIndexMap(tokens, comments)`
assuming each input array is sorted by `range[0]`. Every standard JS
parser (espree, @babel/eslint-parser, @typescript-eslint/parser) honors
that invariant.
When a .gts file has a JS /* */ comment interleaved between templates,
TS-parser comments are spread into program.comments first and Glimmer
template comments get appended — producing an array whose order doesn't
match range order:
const X = <template>{{! glimmer at 22 }}</template>;
/* js at 56 */
const Y = 1;
ast.comments: [[65,87] js, [23,51] glimmer] ← unsorted
The downstream effect is that `sourceCode.getTokenBefore(glimmer)` /
`getTokenAfter(glimmer)` return wrong tokens:
before: ";" @ [63,64] (wrong — that's *after* the comment)
after: "const" @ [88,93] (skips </template>)
Adds two tests:
1. ast.comments is sorted by range[0] — direct structural assertion.
2. getTokenBefore / getTokenAfter on a Glimmer comment return
source-adjacent tokens — end-to-end through Linter.
Both currently fail; they'll pass once program.comments is sorted.1 parent 2b4d6d1 commit b46414f
1 file changed
Lines changed: 87 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
0 commit comments