Skip to content

Commit

Permalink
add eslint rule no-floating-promises in docs and demos dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
wkazmierczak committed Sep 12, 2024
1 parent 65c443c commit 852c932
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 20 deletions.
6 changes: 6 additions & 0 deletions demos/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
}
6 changes: 3 additions & 3 deletions demos/1-videoconferencing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -166,4 +166,4 @@ function sceneWithInputs(n: number): Component {
};
}

runCompositorExample(exampleAsync, DISPLAY_LOGS);
void runCompositorExample(exampleAsync, DISPLAY_LOGS);
6 changes: 3 additions & 3 deletions demos/2-tv_broadcast/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -319,4 +319,4 @@ function logo(): Component {
};
}

runCompositorExample(exampleAsync, DISPLAY_LOGS);
void runCompositorExample(exampleAsync, DISPLAY_LOGS);
8 changes: 4 additions & 4 deletions demos/3-live_stream/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -232,4 +232,4 @@ function baseScene(): Component {
};
}

runCompositorExample(exampleAsync, DISPLAY_LOGS);
void runCompositorExample(exampleAsync, DISPLAY_LOGS);
4 changes: 2 additions & 2 deletions demos/utils/ffmpeg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async function writeVideoAudioSdpFile(
audio_port: number,
destination: string
): Promise<void> {
fs.writeFile(
await fs.writeFile(
destination,
`
v=0
Expand All @@ -100,7 +100,7 @@ a=rtcp-mux
}

async function writeVideoSdpFile(ip: string, port: number, destination: string): Promise<void> {
fs.writeFile(
await fs.writeFile(
destination,
`
v=0
Expand Down
2 changes: 1 addition & 1 deletion demos/utils/generate_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ async function generateTypes() {
fs.writeFileSync(tsOutputPath, typesTs);
}

generateTypes();
void generateTypes();
2 changes: 1 addition & 1 deletion demos/utils/gst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`);
}
Expand Down
4 changes: 2 additions & 2 deletions demos/utils/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
});
Expand All @@ -20,7 +20,7 @@ export async function runCompositorExample(

await fn();
} catch (err) {
logError(err);
void logError(err);
throw err;
}
}
Expand Down
6 changes: 6 additions & 0 deletions docs/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
],
Expand Down
4 changes: 2 additions & 2 deletions docs/src/components/PlaygroundSettingsImages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ function ImagePreview({ image_id, description, filename }: ImagePreviewProps) {
{`Add `}
<code
className={styles.tooltipCode}
onClick={() => {
navigator.clipboard.writeText(json);
onClick={async () => {
await navigator.clipboard.writeText(json);
toast.success('Copied to clipboard!');
}}>
{json}
Expand Down
4 changes: 2 additions & 2 deletions docs/src/components/PlaygroundSettingsInputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ function InputResolutionSelect({
{`Add `}
<code
className={styles.tooltipCode}
onClick={() => {
navigator.clipboard.writeText(json);
onClick={async () => {
await navigator.clipboard.writeText(json);
toast.success('Copied to clipboard!');
}}>
{json}
Expand Down

0 comments on commit 852c932

Please sign in to comment.