Skip to content

Commit

Permalink
Merge pull request #17 from THEOplayer/update-eslint
Browse files Browse the repository at this point in the history
Update to ESLint flat config
  • Loading branch information
MattiasBuelens authored Apr 5, 2024
2 parents 34e43ab + d31b742 commit 8075e7f
Show file tree
Hide file tree
Showing 31 changed files with 1,170 additions and 1,998 deletions.
67 changes: 0 additions & 67 deletions .eslintrc.json

This file was deleted.

5 changes: 3 additions & 2 deletions cmcd/src/CMCDCollector.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChromelessPlayer, CurrentSourceChangeEvent, MediaTrack, MediaType, Quality, Request } from 'theoplayer';
import type { ChromelessPlayer, CurrentSourceChangeEvent, MediaTrack, MediaType, Quality, Request } from 'theoplayer';
import { CMCDObjectType, CMCDPayload, CMCDReservedKey, CMCDStreamingFormat, CMCDStreamType } from './CMCDPayload';
import { Configuration } from './Configuration';
import { calculateBufferSize, getStreamingFormatFromTypedSource } from './PlayerUtils';
Expand Down Expand Up @@ -162,7 +162,7 @@ export class CMCDCollector {
[CMCDReservedKey.OBJECT_TYPE]: CMCDObjectType.KEY_LICENSE_OR_CERTIFICATE
};
}
case 'segment':
case 'segment': {
if (request.subType === 'initialization-segment') {
return {
...sessionKeys,
Expand Down Expand Up @@ -235,6 +235,7 @@ export class CMCDCollector {
// TODO object duration
// TODO next request... and next range
return payload;
}
default:
return {};
}
Expand Down
2 changes: 1 addition & 1 deletion cmcd/src/CMCDConnector.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChromelessPlayer, InterceptableRequest, Request } from 'theoplayer';
import type { ChromelessPlayer, InterceptableRequest, Request } from 'theoplayer';
import { CMCDCollector } from './CMCDCollector';
import { CMCDPayload } from './CMCDPayload';
import { Configuration, TransmissionMode } from './Configuration';
Expand Down
2 changes: 1 addition & 1 deletion cmcd/src/PlayerUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TypedSource } from 'theoplayer';
import type { TypedSource } from 'theoplayer';
import { CMCDStreamingFormat } from './CMCDPayload';

function isM3U8SourceString(source: string): boolean {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InterceptableRequest } from 'theoplayer';
import type { InterceptableRequest } from 'theoplayer';
import { CMCDHeaderName, CMCDPayload } from '../CMCDPayload';
import { extractKeysFor, transformToQueryParameters } from '../CMCDPayloadUtils';
import { TransmissionModeStrategy } from './TransmissionModeStrategy';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InterceptableRequest } from 'theoplayer';
import type { InterceptableRequest } from 'theoplayer';
import { CMCDPayload } from '../CMCDPayload';
import { TransmissionModeStrategy } from './TransmissionModeStrategy';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InterceptableRequest } from 'theoplayer';
import type { InterceptableRequest } from 'theoplayer';
import { CMCDPayload } from '../CMCDPayload';
import { transformToQueryParameters } from '../CMCDPayloadUtils';
import { TransmissionModeStrategy } from './TransmissionModeStrategy';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InterceptableRequest } from 'theoplayer';
import type { InterceptableRequest } from 'theoplayer';
import { CMCDPayload } from '../CMCDPayload';
import { Configuration, TransmissionMode } from '../Configuration';
import { HTTPHeaderTransmissionModeStrategy } from './HTTPHeaderTransmissionModeStrategy';
Expand Down
6 changes: 3 additions & 3 deletions conviva/src/integration/ConvivaConnector.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ChromelessPlayer } from 'theoplayer';
import { ConvivaMetadata } from '@convivainc/conviva-js-coresdk';
import { YospaceConnector } from '@theoplayer/yospace-connector-web';
import type { ChromelessPlayer } from 'theoplayer';
import type { ConvivaMetadata } from '@convivainc/conviva-js-coresdk';
import type { YospaceConnector } from '@theoplayer/yospace-connector-web';
import { ConvivaConfiguration, ConvivaHandler } from './ConvivaHandler';

export class ConvivaConnector {
Expand Down
12 changes: 9 additions & 3 deletions conviva/src/integration/ConvivaHandler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { ChromelessPlayer, SourceDescription, VideoQuality } from 'theoplayer';
import { AdAnalytics, Analytics, Constants, ConvivaMetadata, VideoAnalytics } from '@convivainc/conviva-js-coresdk';
import { YospaceConnector } from '@theoplayer/yospace-connector-web';
import type { ChromelessPlayer, SourceDescription, VideoQuality } from 'theoplayer';
import {
type AdAnalytics,
Analytics,
Constants,
type ConvivaMetadata,
type VideoAnalytics
} from '@convivainc/conviva-js-coresdk';
import type { YospaceConnector } from '@theoplayer/yospace-connector-web';
import { CONVIVA_CALLBACK_FUNCTIONS } from './ConvivaCallbackFunctions';
import {
calculateBufferLength,
Expand Down
6 changes: 3 additions & 3 deletions conviva/src/integration/ads/AdReporter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Ad, AdBreak, ChromelessPlayer, GoogleImaAd } from 'theoplayer';
import { AdAnalytics, Constants, ConvivaMetadata, VideoAnalytics } from '@convivainc/conviva-js-coresdk';
import type { Ad, AdBreak, ChromelessPlayer, GoogleImaAd } from 'theoplayer';
import { type AdAnalytics, Constants, type ConvivaMetadata, type VideoAnalytics } from '@convivainc/conviva-js-coresdk';
import { calculateAdType, calculateCurrentAdBreakInfo, collectAdMetadata, collectPlayerInfo } from '../../utils/Utils';

export class AdReporter {
Expand Down Expand Up @@ -52,7 +52,7 @@ export class AdReporter {
// there are two tags that are critical:
// - `c3.csid`: the content’s sessionID;
// - `contentAssetName`: the content's assetName.
// @ts-ignore: getSessionId() is not present in type declarations.
// @ts-expect-error: getSessionId() is not present in type declarations.
adMetadata['c3.csid'] = `${this.convivaVideoAnalytics.getSessionId()}`;
adMetadata.contentAssetName =
this.contentInfo()[Constants.ASSET_NAME] ?? this.player.source?.metadata?.title ?? 'NA';
Expand Down
4 changes: 2 additions & 2 deletions conviva/src/integration/ads/VerizonAdReporter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
ChromelessPlayer,
VerizonMediaAdBeginEvent,
VerizonMediaAdBreak,
Expand All @@ -7,7 +7,7 @@ import {
VerizonMediaRemoveAdBreakEvent,
VideoQuality
} from 'theoplayer';
import { AdAnalytics, Constants, VideoAnalytics } from '@convivainc/conviva-js-coresdk';
import { type AdAnalytics, Constants, type VideoAnalytics } from '@convivainc/conviva-js-coresdk';
import { calculateVerizonAdBreakInfo, collectPlayerInfo, collectVerizonAdMetadata } from '../../utils/Utils';

export class VerizonAdReporter {
Expand Down
12 changes: 6 additions & 6 deletions conviva/src/integration/ads/YospaceAdReporter.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ChromelessPlayer, VideoQuality } from 'theoplayer';
import { AdAnalytics, Constants, VideoAnalytics } from '@convivainc/conviva-js-coresdk';
import type { ChromelessPlayer, VideoQuality } from 'theoplayer';
import { type AdAnalytics, Constants, type VideoAnalytics } from '@convivainc/conviva-js-coresdk';
import {
AdBreak,
AdVert,
AnalyticEventObserver,
type AdBreak,
type AdVert,
type AnalyticEventObserver,
SessionErrorCode,
YospaceConnector
type YospaceConnector
} from '@theoplayer/yospace-connector-web';
import { collectPlayerInfo, collectYospaceAdMetadata } from '../../utils/Utils';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AdsEventMap, EventDispatcher } from 'theoplayer';
import type { AdsEventMap, EventDispatcher } from 'theoplayer';

declare module 'theoplayer' {
interface Ads extends EventDispatcher<AdsEventMap> {
Expand Down
25 changes: 15 additions & 10 deletions conviva/src/utils/Utils.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import {
Constants,
ConvivaAdBreakInfo,
ConvivaDeviceMetadata,
ConvivaMetadata,
ConvivaOptions,
ConvivaPlayerInfo
type ConvivaAdBreakInfo,
type ConvivaDeviceMetadata,
type ConvivaMetadata,
type ConvivaOptions,
type ConvivaPlayerInfo
} from '@convivainc/conviva-js-coresdk';
import { AdVert } from '@theoplayer/yospace-connector-web';
import { Ad, AdBreak, ChromelessPlayer, GoogleImaAd, VerizonMediaAd, VerizonMediaAdBreak, version } from 'theoplayer';
import type { AdVert } from '@theoplayer/yospace-connector-web';
import {
type Ad,
type AdBreak,
type ChromelessPlayer,
type GoogleImaAd,
type VerizonMediaAd,
type VerizonMediaAdBreak,
version
} from 'theoplayer';
import { ConvivaConfiguration } from '../integration/ConvivaHandler';

export function collectDeviceMetadata(): ConvivaDeviceMetadata {
Expand All @@ -17,8 +25,6 @@ export function collectDeviceMetadata(): ConvivaDeviceMetadata {
};
}

type AdBreakPosition = 'preroll' | 'midroll' | 'postroll';

export function calculateAdType(player: ChromelessPlayer) {
return player.source?.ads?.length ? Constants.AdType.CLIENT_SIDE : Constants.AdType.SERVER_SIDE;
}
Expand Down Expand Up @@ -77,7 +83,6 @@ export function collectContentMetadata(
if (!Number.isNaN(duration) && duration !== Infinity) {
contentInfo[Constants.DURATION] = duration;
}
// @ts-ignore
return {
...configuredContentMetadata,
...contentInfo
Expand Down
22 changes: 22 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// @ts-check

import eslint from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier';
import typescriptEslint from 'typescript-eslint';

export default typescriptEslint.config(
eslint.configs.recommended,
...typescriptEslint.configs.recommended,
eslintConfigPrettier,
{
rules: {
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_'
}
],
'@typescript-eslint/no-explicit-any': 'off'
}
}
);
2 changes: 1 addition & 1 deletion nielsen/src/integration/NielsenConnector.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChromelessPlayer } from 'theoplayer';
import type { ChromelessPlayer } from 'theoplayer';
import { NielsenOptions } from '../nielsen/Types';
import { NielsenHandler } from './NielsenHandler';

Expand Down
24 changes: 17 additions & 7 deletions nielsen/src/integration/NielsenHandler.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { Ad, AddTrackEvent, ChromelessPlayer, TextTrack, TextTrackEnterCueEvent, VolumeChangeEvent } from 'theoplayer';
import type {
Ad,
AddTrackEvent,
ChromelessPlayer,
TextTrack,
TextTrackEnterCueEvent,
VolumeChangeEvent
} from 'theoplayer';
import { loadNielsenLibrary } from '../nielsen/NOLBUNDLE';
import { AdMetadata, ContentMetadata, NielsenOptions } from '../nielsen/Types';
import { getAdType } from '../utils/Util';

const EMSG_PRIV_SUFFIX = "PRIV{";
const EMSG_PAYLOAD_SUFFIX = "payload=";
const EMSG_PRIV_SUFFIX = 'PRIV{';
const EMSG_PAYLOAD_SUFFIX = 'payload=';

export class NielsenHandler {
private player: ChromelessPlayer;
Expand Down Expand Up @@ -121,7 +128,7 @@ export class NielsenHandler {
if (content.id === 'PRIV' && content.ownerIdentifier.indexOf('www.nielsen.com') !== -1) {
this.nSdkInstance.ggPM('sendID3', content.ownerIdentifier);
}
}
};

private handleNielsenEmsgPayload = (content: any) => {
const cueContentText = this.decoder.decode(content);
Expand All @@ -143,16 +150,19 @@ export class NielsenHandler {
// - drop everything before ID3 PRIV{
let sanitizedPayload = payload.replace(/[^ -~]|\D+$/g, '');
const privIndex = sanitizedPayload.indexOf(EMSG_PRIV_SUFFIX);
sanitizedPayload = privIndex !== -1 ? sanitizedPayload.substring(privIndex + EMSG_PRIV_SUFFIX.length) : sanitizedPayload;
sanitizedPayload =
privIndex !== -1
? sanitizedPayload.substring(privIndex + EMSG_PRIV_SUFFIX.length)
: sanitizedPayload;

// send payload. Note that there is no separate method for sending emsg content.
this.nSdkInstance.ggPM('sendID3', sanitizedPayload);
}
} catch (error) {
console.error("NielsenConnector", "Failed to parse Nielsen payload", error);
console.error('NielsenConnector', 'Failed to parse Nielsen payload', error);
}
}
}
};

private onAdBegin = () => {
const currentAd = this.player.ads!.currentAds.filter((ad: Ad) => ad.type === 'linear');
Expand Down
2 changes: 1 addition & 1 deletion nielsen/src/utils/Util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AdBreak } from 'theoplayer';
import type { AdBreak } from 'theoplayer';
import { AdType } from '../nielsen/Types';

export function getAdType(adBreak: AdBreak): AdType {
Expand Down
Loading

0 comments on commit 8075e7f

Please sign in to comment.