From 852c932b1e36db76a8c9ed94a8a720fe02ceb7df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Ka=C5=BAmierczak?= Date: Thu, 12 Sep 2024 17:32:00 +0200 Subject: [PATCH] add eslint rule no-floating-promises in docs and demos dirs --- demos/.eslintrc.json | 6 ++++++ demos/1-videoconferencing/index.ts | 6 +++--- demos/2-tv_broadcast/index.ts | 6 +++--- demos/3-live_stream/index.ts | 8 ++++---- demos/utils/ffmpeg.ts | 4 ++-- demos/utils/generate_types.ts | 2 +- demos/utils/gst.ts | 2 +- demos/utils/run.ts | 4 ++-- docs/.eslintrc.json | 6 ++++++ docs/src/components/PlaygroundSettingsImages.tsx | 4 ++-- docs/src/components/PlaygroundSettingsInputs.tsx | 4 ++-- 11 files changed, 32 insertions(+), 20 deletions(-) diff --git a/demos/.eslintrc.json b/demos/.eslintrc.json index f61c0e759..fc0d40cca 100644 --- a/demos/.eslintrc.json +++ b/demos/.eslintrc.json @@ -14,9 +14,15 @@ "prettier" ], "parser": "@typescript-eslint/parser", + "parserOptions": { + "project": [ + "tsconfig.json" + ] + }, "rules": { "prettier/prettier": ["error"], "@typescript-eslint/no-explicit-any": [0, {}], + "@typescript-eslint/no-floating-promises": "error", "no-constant-condition": [0] } } diff --git a/demos/1-videoconferencing/index.ts b/demos/1-videoconferencing/index.ts index 165f62ae7..7070c9b63 100644 --- a/demos/1-videoconferencing/index.ts +++ b/demos/1-videoconferencing/index.ts @@ -65,11 +65,11 @@ async function exampleAsync() { }); if (useWebCam) { - gstStreamWebcam(IP, INPUT_PORT, DISPLAY_LOGS); + void gstStreamWebcam(IP, INPUT_PORT, DISPLAY_LOGS); } else { const callPath = path.join(__dirname, '../assets/call.mp4'); await downloadAsync(CALL_URL, callPath); - ffmpegSendVideoFromMp4(INPUT_PORT, callPath, DISPLAY_LOGS); + void ffmpegSendVideoFromMp4(INPUT_PORT, callPath, DISPLAY_LOGS); } await startAsync(); @@ -166,4 +166,4 @@ function sceneWithInputs(n: number): Component { }; } -runCompositorExample(exampleAsync, DISPLAY_LOGS); +void runCompositorExample(exampleAsync, DISPLAY_LOGS); diff --git a/demos/2-tv_broadcast/index.ts b/demos/2-tv_broadcast/index.ts index dcb7903ef..ac934e6d3 100644 --- a/demos/2-tv_broadcast/index.ts +++ b/demos/2-tv_broadcast/index.ts @@ -37,7 +37,7 @@ const LOGO_URL = 'https://raw.githubusercontent.com/membraneframework-labs/video_compositor_snapshot_tests/main/demo_assets/logo.png'; async function exampleAsync() { - ffplayStartPlayerAsync(IP, DISPLAY_LOGS, VIDEO_OUTPUT_PORT, AUDIO_OUTPUT_PORT); + void ffplayStartPlayerAsync(IP, DISPLAY_LOGS, VIDEO_OUTPUT_PORT, AUDIO_OUTPUT_PORT); await sleepAsync(2000); process.env.LIVE_COMPOSITOR_LOGGER_LEVEL = 'debug'; @@ -103,7 +103,7 @@ async function exampleAsync() { }, }); - ffmpegSendVideoFromMp4(INPUT_PORT, TV_PATH, DISPLAY_LOGS); + void ffmpegSendVideoFromMp4(INPUT_PORT, TV_PATH, DISPLAY_LOGS); await startAsync(); // First update to set start position of the bunny for transition @@ -319,4 +319,4 @@ function logo(): Component { }; } -runCompositorExample(exampleAsync, DISPLAY_LOGS); +void runCompositorExample(exampleAsync, DISPLAY_LOGS); diff --git a/demos/3-live_stream/index.ts b/demos/3-live_stream/index.ts index cc38c58b2..4e6e35754 100644 --- a/demos/3-live_stream/index.ts +++ b/demos/3-live_stream/index.ts @@ -100,13 +100,13 @@ async function exampleAsync() { }); if (useWebCam) { - gstStreamWebcam(IP, WEBCAM_INPUT_PORT, DISPLAY_LOGS); + void gstStreamWebcam(IP, WEBCAM_INPUT_PORT, DISPLAY_LOGS); } else { const callPath = path.join(__dirname, '../assets/call.mp4'); await downloadAsync(CALL_URL, callPath); - ffmpegSendVideoFromMp4(WEBCAM_INPUT_PORT, callPath, DISPLAY_LOGS); + void ffmpegSendVideoFromMp4(WEBCAM_INPUT_PORT, callPath, DISPLAY_LOGS); } - ffmpegSendVideoFromMp4(GAMEPLAY_PORT, gameplayPath, DISPLAY_LOGS); + void ffmpegSendVideoFromMp4(GAMEPLAY_PORT, gameplayPath, DISPLAY_LOGS); await sleepAsync(2000); await startAsync(); @@ -232,4 +232,4 @@ function baseScene(): Component { }; } -runCompositorExample(exampleAsync, DISPLAY_LOGS); +void runCompositorExample(exampleAsync, DISPLAY_LOGS); diff --git a/demos/utils/ffmpeg.ts b/demos/utils/ffmpeg.ts index 42842881a..bf0aeefd9 100644 --- a/demos/utils/ffmpeg.ts +++ b/demos/utils/ffmpeg.ts @@ -81,7 +81,7 @@ async function writeVideoAudioSdpFile( audio_port: number, destination: string ): Promise { - fs.writeFile( + await fs.writeFile( destination, ` v=0 @@ -100,7 +100,7 @@ a=rtcp-mux } async function writeVideoSdpFile(ip: string, port: number, destination: string): Promise { - fs.writeFile( + await fs.writeFile( destination, ` v=0 diff --git a/demos/utils/generate_types.ts b/demos/utils/generate_types.ts index fc31ca72a..5eb5e32bf 100644 --- a/demos/utils/generate_types.ts +++ b/demos/utils/generate_types.ts @@ -12,4 +12,4 @@ async function generateTypes() { fs.writeFileSync(tsOutputPath, typesTs); } -generateTypes(); +void generateTypes(); diff --git a/demos/utils/gst.ts b/demos/utils/gst.ts index ef1d54a20..3a37ad7b7 100644 --- a/demos/utils/gst.ts +++ b/demos/utils/gst.ts @@ -31,7 +31,7 @@ export function gstStreamWebcam(ip: string, port: number, displayOutput: boolean function checkGstPlugins(plugins: string[]) { plugins.forEach(plugin => { - isGstPluginAvailable(plugin).then(isAvailable => { + void isGstPluginAvailable(plugin).then(isAvailable => { if (!isAvailable) { throw Error(`Gstreamer plugin: ${plugin} is not available.`); } diff --git a/demos/utils/run.ts b/demos/utils/run.ts index 2362e6ebe..edcd85aaf 100644 --- a/demos/utils/run.ts +++ b/demos/utils/run.ts @@ -11,7 +11,7 @@ export async function runCompositorExample( await ensureCompositorReadyAsync(); const { command, args, cwd } = getCompositorRunCmd(); try { - spawn(command, args, { + void spawn(command, args, { displayOutput: displayOutput, cwd: cwd ?? process.cwd(), }); @@ -20,7 +20,7 @@ export async function runCompositorExample( await fn(); } catch (err) { - logError(err); + void logError(err); throw err; } } diff --git a/docs/.eslintrc.json b/docs/.eslintrc.json index 3a6771e5d..0145fb930 100644 --- a/docs/.eslintrc.json +++ b/docs/.eslintrc.json @@ -16,11 +16,17 @@ "prettier" ], "parser": "@typescript-eslint/parser", + "parserOptions": { + "project": [ + "tsconfig.json" + ] + }, "rules": { "prettier/prettier": [ "error" ], "@typescript-eslint/no-explicit-any": 0, + "@typescript-eslint/no-floating-promises": "error", "no-constant-condition": [ 0 ], diff --git a/docs/src/components/PlaygroundSettingsImages.tsx b/docs/src/components/PlaygroundSettingsImages.tsx index 9bad6f485..1e4c6d222 100644 --- a/docs/src/components/PlaygroundSettingsImages.tsx +++ b/docs/src/components/PlaygroundSettingsImages.tsx @@ -111,8 +111,8 @@ function ImagePreview({ image_id, description, filename }: ImagePreviewProps) { {`Add `} { - navigator.clipboard.writeText(json); + onClick={async () => { + await navigator.clipboard.writeText(json); toast.success('Copied to clipboard!'); }}> {json} diff --git a/docs/src/components/PlaygroundSettingsInputs.tsx b/docs/src/components/PlaygroundSettingsInputs.tsx index e81ef0f00..e13580d4c 100644 --- a/docs/src/components/PlaygroundSettingsInputs.tsx +++ b/docs/src/components/PlaygroundSettingsInputs.tsx @@ -83,8 +83,8 @@ function InputResolutionSelect({ {`Add `} { - navigator.clipboard.writeText(json); + onClick={async () => { + await navigator.clipboard.writeText(json); toast.success('Copied to clipboard!'); }}> {json}