Skip to content

Commit e0e1d66

Browse files
authored
Merge pull request #11 from takikawa/ignore-list
Add support for recent ignore list tests
2 parents bc72ed9 + 8300b72 commit e0e1d66

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/spec-tests.test.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ const skippedTests = [
1919
"validMappingFieldsWith32BitMaxValues",
2020
// Source maps library errors on this.
2121
"validMappingLargeVLQ",
22-
// Ignore list unsupported for now.
23-
"ignoreListWrongType1",
24-
"ignoreListWrongType2",
25-
"ignoreListWrongType3",
26-
"ignoreListOutOfBounds",
2722
];
2823

2924
test.describe("runSourceMapSpecTests", () => {

src/validators/SourceMapFormatValidator.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,27 @@ function validateSourceMap(sourceMap : any) : Error[] {
6060
if (x !== null && typeof x !== "string") errors.push(new Error(`There is a source content with an invalid format on the index ${i}. Each content should be defined as a strings or null`))
6161
})
6262
}
63+
64+
if ("ignoreList" in sourceMap) {
65+
if (!Array.isArray(sourceMap.ignoreList))
66+
errors.push(new Error('Source map "ignoreList" field is invalid.'));
67+
else {
68+
sourceMap.ignoreList.forEach((x: unknown, i: number) => {
69+
if (!Number.isInteger(x))
70+
errors.push(
71+
new Error(
72+
`There is an ignoreList entry with an invalid format at the index ${i}. Each content should be defined as a number`,
73+
),
74+
);
75+
if ((x as number) >= sourceMap.sources.length || (x as number) < 0)
76+
errors.push(
77+
new Error(
78+
`There is an ignoreList entry at index ${i} with an out-of-bounds value ${x}.`,
79+
),
80+
);
81+
});
82+
}
83+
}
6384
}
6485

6586
return errors;

0 commit comments

Comments
 (0)