Skip to content

Commit

Permalink
Merge pull request #1507 from canalplus/misc/de-eslint-code
Browse files Browse the repository at this point in the history
Limit reliance on eslint in the RxPlayer's code
  • Loading branch information
peaBerberian authored Sep 4, 2024
2 parents 683b02e + 15fb3d7 commit 19c66e6
Show file tree
Hide file tree
Showing 242 changed files with 2,846 additions and 2,603 deletions.
2 changes: 1 addition & 1 deletion demo/scripts/components/VideoThumbnail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default function VideoThumbnail({
} else {
hideSpinner();

/* eslint-disable-next-line no-console */
// eslint-disable-next-line no-console
console.error("Error while loading thumbnails:", err);
}
});
Expand Down
8 changes: 4 additions & 4 deletions demo/scripts/controllers/ContentList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ function ContentList({
});
},
() => {
/* eslint-disable-next-line no-console */
// eslint-disable-next-line no-console
console.error("Could not construct key systems option");
},
);
Expand Down Expand Up @@ -335,7 +335,7 @@ function ContentList({
});
},
() => {
/* eslint-disable-next-line no-console */
// eslint-disable-next-line no-console
console.error("Could not construct key systems option");
},
);
Expand Down Expand Up @@ -547,7 +547,7 @@ function ContentList({
const contents = contentList[transportType] ?? [];
const firstEnabledContentIndex = contents.findIndex((c) => c.id === storedContent.id);
if (firstEnabledContentIndex < 0) {
/* eslint-disable-next-line no-console */
// eslint-disable-next-line no-console
console.warn("Stored content not found in local storage.");
changeSelectedContent(0, contents[0]);
} else {
Expand All @@ -563,7 +563,7 @@ function ContentList({
const content = contentsToSelect[contentChoiceIndex];
if (content) {
if (content.id === undefined) {
/* eslint-disable-next-line no-console */
// eslint-disable-next-line no-console
console.error("Cannot erase: no id on the content");
return;
}
Expand Down
2 changes: 1 addition & 1 deletion demo/scripts/controllers/ControlBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function ControlBar({
const onLiveDotClick = React.useCallback(() => {
const livePos = livePosition ?? maximumPosition;
if (livePos == null) {
/* eslint-disable-next-line no-console */
// eslint-disable-next-line no-console
console.error("Cannot go back to live: live position not found");
return;
}
Expand Down
2 changes: 1 addition & 1 deletion demo/scripts/controllers/knobs/AudioTrack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function AudioTrackKnob({
if (track !== undefined) {
player.actions.setAudioTrack(track);
} else {
/* eslint-disable-next-line no-console */
// eslint-disable-next-line no-console
console.error("Error: audio track not found");
}
},
Expand Down
2 changes: 1 addition & 1 deletion demo/scripts/controllers/knobs/SpeedKnob.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function SpeedKnob({
if (rate !== undefined) {
player.actions.setPlaybackRate(rate);
} else {
/* eslint-disable-next-line no-console */
// eslint-disable-next-line no-console
console.error("Error: playback rate not found");
}
}
Expand Down
2 changes: 1 addition & 1 deletion demo/scripts/controllers/knobs/Subtitles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function SubtitlesKnob({
if (track !== undefined) {
player.actions.setTextTrack(track);
} else {
/* eslint-disable-next-line no-console */
// eslint-disable-next-line no-console
console.error("Error: subtitles track not found");
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion demo/scripts/controllers/knobs/VideoTrack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function VideoTrackKnob({
if (track !== undefined) {
player.actions.setVideoTrack(track);
} else {
/* eslint-disable-next-line no-console */
// eslint-disable-next-line no-console
console.error("Error: video track not found");
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion demo/scripts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Main from "./controllers/Main";
window.onload = function (): void {
const rootElt = document.getElementById("player-container");
if (rootElt === null) {
/* eslint-disable-next-line no-console */
// eslint-disable-next-line no-console
console.error("Error: missing `player-container` element");
return;
}
Expand Down
2 changes: 1 addition & 1 deletion demo/scripts/lib/declareModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export function declareModule<TStateObject extends object, TModuleArg, TActions>
try {
listener(stateObject[stateName]);
} catch (e) {
/* eslint-disable-next-line no-console */
// eslint-disable-next-line no-console
console.error("EventEmitter: listener error", e instanceof Error ? e : null);
}
});
Expand Down
83 changes: 0 additions & 83 deletions demo/scripts/lib/fullscreen.ts

This file was deleted.

4 changes: 2 additions & 2 deletions demo/scripts/lib/localStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { localStorage } = window;
export const hasLocalStorage = !!localStorage;

if (!hasLocalStorage) {
/* eslint-disable-next-line no-console */
// eslint-disable-next-line no-console
console.warn(
"`localStorage` is not available." +
" You will not be able to store content information.",
Expand Down Expand Up @@ -33,7 +33,7 @@ export function getLocalStorageContents(): IStoredContentInfo[] {
const parsed = JSON.parse(localContentItems) as IStoredContentInfo[];
localStorageContents.push(...parsed);
} catch (err) {
/* eslint-disable-next-line */
// eslint-disable-next-line
console.warn("Demo: Can't parse local storage content.");
}
}
Expand Down
28 changes: 18 additions & 10 deletions demo/scripts/modules/player/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,19 @@ RxPlayer.addFeatures([
MULTI_THREAD,
]);

/* eslint-disable */
(window as any).RxPlayer = RxPlayer;
/* eslint-enable */
(
window as typeof window & {
RxPlayer: typeof RxPlayer;
}
).RxPlayer = RxPlayer;

declare const __INCLUDE_WASM_PARSER__: boolean;

/* eslint-disable no-undef */
// eslint-disable-next-line no-undef
if (__INCLUDE_WASM_PARSER__) {
/* eslint-enable no-undef */
RxPlayer.addFeatures([DASH_WASM]);
DASH_WASM.initialize({ wasmUrl: "./mpd-parser.wasm" }).catch((err) => {
/* eslint-disable-next-line no-console */
// eslint-disable-next-line no-console
console.error("Error when initializing WASM DASH MPD parser:", err);
});
}
Expand Down Expand Up @@ -225,9 +226,16 @@ const PlayerModule = declareModule(
let debugEltInstance: { dispose(): void } | undefined;

// facilitate DEV mode
/* eslint-disable */
(window as any).player = (window as any).rxPlayer = player;
/* eslint-enable */
(
window as typeof window & {
player: RxPlayer;
}
).player = player;
(
window as typeof window & {
rxPlayer: RxPlayer;
}
).rxPlayer = player;

linkPlayerEventsToState(player, state, abortSignal);

Expand Down Expand Up @@ -450,7 +458,7 @@ const PlayerModule = declareModule(
dashWasmUrl: "./mpd-parser.wasm",
})
.catch((err) => {
/* eslint-disable-next-line no-console */
// eslint-disable-next-line no-console
console.error("Error when attaching worker:", err);
});
}
Expand Down
5 changes: 0 additions & 5 deletions scripts/build_demo.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,13 @@ export default function buildDemo(options) {
* script.
*/
function displayHelp() {
/* eslint-disable no-console */
console.log(
/* eslint-disable indent */
`Usage: node build_demo.mjs [options]
Options:
-h, --help Display this help
-m, --minify Minify the built demo
-p, --production-mode Build all files in production mode (less runtime checks, mostly).
-w, --watch Re-build each time either the demo or library files change
--include-wasm The demo will be able to request the WebAssembly MPD parser (if available).`,

/* eslint-enable indent */
);
/* eslint-enable no-console */
}
2 changes: 0 additions & 2 deletions scripts/check_nodejs_import_compatibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,4 @@ if (typeof Tools !== "object" || Tools === null) {
throw new Error('Invalid "Tools" object exported.');
}

/* eslint-disable no-console */
console.log("SUCCESS!");
/* eslint-enable no-console */
5 changes: 0 additions & 5 deletions scripts/generate_build.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env node
/* eslint-env node */

/**
* =================
Expand Down Expand Up @@ -167,14 +166,10 @@ function spawnProm(command, args, errorOnCode) {
* script.
*/
function displayHelp() {
/* eslint-disable no-console */
console.log(
/* eslint-disable indent */
`Usage: node build_worker.mjs [options]
Options:
-h, --help Display this help
-p, --dev-mode Build all files in development mode (more runtime checks, worker not minified)`,
/* eslint-enable indent */
);
/* eslint-enable no-console */
}
1 change: 0 additions & 1 deletion scripts/generate_demo_list.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env node
/* eslint-env node */

/**
* Generate demo list
Expand Down
2 changes: 0 additions & 2 deletions scripts/generate_documentation_list.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env node
/* eslint-env node */

/**
* Generate documentation list
* ===========================
Expand Down
6 changes: 0 additions & 6 deletions scripts/launch_static_server.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env node
/* eslint-env node */

/**
* Launch static server
* ====================
Expand Down Expand Up @@ -117,7 +115,6 @@ export default function launchStaticServer(path, config) {
function onHttpConnection(err) {
if (err) {
if (config.verbose) {
/* eslint-disable-next-line no-console */
console.error(
`\x1b[31m[${getHumanReadableHours()}]\x1b[0m ` +
"Could not start static HTTP server:",
Expand All @@ -134,7 +131,6 @@ export default function launchStaticServer(path, config) {
return;
}
httpServerStatus = "success";
/* eslint-disable-next-line no-console */
console.log(
`[${getHumanReadableHours()}] ` +
`Listening HTTP at http://localhost:${config.httpPort}`,
Expand All @@ -147,7 +143,6 @@ export default function launchStaticServer(path, config) {
function onHttpsConnection(err) {
if (err) {
if (config.verbose) {
/* eslint-disable-next-line no-console */
console.error(
`\x1b[31m[${getHumanReadableHours()}]\x1b[0m ` +
"Could not start static HTTPS server:",
Expand All @@ -164,7 +159,6 @@ export default function launchStaticServer(path, config) {
return;
}
httpsServerStatus = "success";
/* eslint-disable-next-line no-console */
console.log(
`[${getHumanReadableHours()}] ` +
`Listening HTTPS at https://localhost:${config.httpsPort}`,
Expand Down
4 changes: 0 additions & 4 deletions scripts/run_bundler.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,7 @@ export default async function runBundler(inputFile, options) {
* script.
*/
function displayHelp() {
/* eslint-disable no-console */
console.log(
/* eslint-disable indent */
`Usage: node run_bundler.mjs input-file [options]
Available options:
-h, --help Display this help message
Expand All @@ -193,7 +191,5 @@ Available options:
symbol) on the bundle.
-s, --silent Don't log to stdout/stderr when bundling
-w, --watch Re-build each time either the files it depends on changed`,
/* eslint-enable indent */
);
/* eslint-enable no-console */
}
Loading

0 comments on commit 19c66e6

Please sign in to comment.