Skip to content

Commit

Permalink
Add eslint rule @typescript-eslint/no-floating-promises in demos an…
Browse files Browse the repository at this point in the history
…d `docs` directory (#769)
  • Loading branch information
wkazmierczak authored Sep 16, 2024
1 parent c131f34 commit 6c9d606
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 28 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
],
"url": "./schemas/scene.schema.json"
}
]
],
"eslint.workingDirectories": [{ "mode": "auto" }]
}
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 @@ -36,7 +36,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 @@ -102,7 +102,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 @@ -318,4 +318,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();
13 changes: 7 additions & 6 deletions demos/utils/gst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function gstStreamWebcam(ip: string, port: number, displayOutput: boolean
: ['v4l2src', 'x264enc', 'tune=zerolatency bitrate=2000 speed-preset=superfast'];

const plugins = [gstWebcamSource, 'videoconvert', gstEncoder, 'rtph264pay', 'udpsink'];
checkGstPlugins(plugins);
void checkGstPlugins(plugins);

const gstCommand =
`gst-launch-1.0 -v ` +
Expand All @@ -29,14 +29,15 @@ export function gstStreamWebcam(ip: string, port: number, displayOutput: boolean
return spawn('bash', ['-c', gstCommand], { displayOutput });
}

function checkGstPlugins(plugins: string[]) {
plugins.forEach(plugin => {
isGstPluginAvailable(plugin).then(isAvailable => {
async function checkGstPlugins(plugins: string[]) {
await Promise.all(
plugins.map(async plugin => {
const isAvailable = await isGstPluginAvailable(plugin);
if (!isAvailable) {
throw Error(`Gstreamer plugin: ${plugin} is not available.`);
}
});
});
})
);
}

function isGstPluginAvailable(pluginName: string): Promise<boolean> {
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);
await 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
4 changes: 2 additions & 2 deletions docs/src/components/PlaygroundSettingsShaders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ function ShaderInfo({ shader_id, description, tooltipJson }: ShaderInfoProps) {
{`Add `}
<code
className={styles.tooltipCode}
onClick={() => {
navigator.clipboard.writeText(tooltipJson);
onClick={async () => {
await navigator.clipboard.writeText(tooltipJson);
toast.success('Copied to clipboard!');
}}>
{tooltipJson}
Expand Down

0 comments on commit 6c9d606

Please sign in to comment.