From 16793c4d0e107471f20f35d9b95cbc959bf22c29 Mon Sep 17 00:00:00 2001 From: Matthias Van Parijs Date: Tue, 8 Oct 2024 16:53:54 +0200 Subject: [PATCH] chore: Added eslint to stitcher --- packages/stitcher/src/parser/lexical-parse.ts | 10 +++++++--- packages/stitcher/src/parser/parse.ts | 4 ++-- scripts/code-eslint.sh | 4 +++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/stitcher/src/parser/lexical-parse.ts b/packages/stitcher/src/parser/lexical-parse.ts index f67c0e8d..be89e5ec 100644 --- a/packages/stitcher/src/parser/lexical-parse.ts +++ b/packages/stitcher/src/parser/lexical-parse.ts @@ -89,7 +89,7 @@ function parseLine(line: string): Tag | null { } throw new Error("EXT-X-PLAYLIST-TYPE: param must be EVENT or VOD"); - case "EXTINF": + case "EXTINF": { assert(param, "EXTINF: no param"); const chunks = param.split(","); return [ @@ -98,6 +98,7 @@ function parseLine(line: string): Tag | null { duration: parseFloat(chunks[0]), }, ]; + } case "EXT-X-STREAM-INF": { assert(param, "EXT-X-STREAM-INF: no param"); @@ -110,13 +111,14 @@ function parseLine(line: string): Tag | null { attrs.bandwidth = Number.parseFloat(value); break; - case "RESOLUTION": + case "RESOLUTION": { const chunks = value.split("x"); attrs.resolution = { width: parseFloat(chunks[0]), height: parseFloat(chunks[1]), }; break; + } case "AUDIO": attrs.audio = value; @@ -159,6 +161,7 @@ function parseLine(line: string): Tag | null { } else { throw new Error("EXT-X-MEDIA: invalid type param"); } + break; case "GROUP-ID": attrs.groupId = value; break; @@ -229,7 +232,7 @@ function parseLine(line: string): Tag | null { case "START-DATE": attrs.startDate = DateTime.fromISO(value); break; - default: + default: { if (!key.startsWith("X-")) { break; } @@ -248,6 +251,7 @@ function parseLine(line: string): Tag | null { } break; + } } }); diff --git a/packages/stitcher/src/parser/parse.ts b/packages/stitcher/src/parser/parse.ts index 857bc6ce..3c6d73d2 100644 --- a/packages/stitcher/src/parser/parse.ts +++ b/packages/stitcher/src/parser/parse.ts @@ -21,7 +21,7 @@ function formatMediaPlaylist(tags: Tag[]): MediaPlaylist { let mediaSequenceBase: number | undefined; let discontinuitySequenceBase: number | undefined; let map: MediaInitializationSection | undefined; - let dateRanges: DateRange[] = []; + const dateRanges: DateRange[] = []; tags.forEach(([name, value]) => { if (name === "EXT-X-TARGETDURATION") { @@ -56,7 +56,7 @@ function formatMediaPlaylist(tags: Tag[]): MediaPlaylist { } let segmentStart = index; - let segmentEnd = index + 1; + const segmentEnd = index + 1; for (let i = index; i > 0; i--) { if (tags[i][0] === "LITERAL") { segmentStart = i + 1; diff --git a/scripts/code-eslint.sh b/scripts/code-eslint.sh index 24ecaaeb..f8e3e982 100755 --- a/scripts/code-eslint.sh +++ b/scripts/code-eslint.sh @@ -8,4 +8,6 @@ echo "✅ eslint(player)" eslint "packages/shared/src/**/*.ts" echo "✅ eslint(shared)" eslint "packages/dashboard/src/**/*.ts" "packages/dashboard/src/**/*.tsx" -echo "✅ eslint(dashboard)" \ No newline at end of file +echo "✅ eslint(dashboard)" +eslint "packages/stitcher/src/**/*.ts" +echo "✅ eslint(stitcher)" \ No newline at end of file