Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanTGold committed Dec 28, 2023
1 parent bfaa3f4 commit 1ff11d2
Show file tree
Hide file tree
Showing 32 changed files with 83 additions and 80 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
"build": "yarn run clean && yarn run ovp:build:prod && yarn run ott:build:prod && yarn run build:types",
"build:types": "tsc --build tsconfig-lib.json && mkdir -p lib && api-extractor run --local",
"type-check": "tsc --noEmit",
"type-check:watch": "npm run type-check -- --watch",
"type-check:watch": "yarn run type-check -- --watch",
"test": "karma start karma.conf.js",
"test:debug": "DEBUG_UNIT_TESTS=1 karma start karma.conf.js --auto-watch --no-single-run --browsers Chrome",
"test:watch": "karma start karma.conf.js --auto-watch --no-single-run",
"lint": "eslint src/ tests/ --ext .js --ext .ts",
"lint:fix": "npm run lint -- --fix",
"lint:fix": "yarn run lint -- --fix",
"prettier": "prettier --write .",
"pushTaggedRelease": "git push --follow-tags --no-verify origin master",
"release": "standard-version"
Expand All @@ -63,6 +63,7 @@
"@babel/preset-env": "^7.22.20",
"@babel/preset-typescript": "^7.22.15",
"@microsoft/api-extractor": "^7.38.0",
"@playkit-js/browserslist-config": "^1.0.5",
"@types/chai": "^4.3.3",
"@types/mocha": "^9.1.1",
"@types/sinon": "^10.0.20",
Expand Down Expand Up @@ -92,12 +93,11 @@
"typescript": "^5.2.2",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1",
"@playkit-js/browserslist-config": "1.0.0"
"webpack-dev-server": "^4.15.1"
},
"standard-version": {
"scripts": {
"precommit": "tmp=$(npm run build:ovp && yarn run build:ott)"
"precommit": "tmp=$(yarn run build:ovp && yarn run build:ott)"
}
}
}
2 changes: 1 addition & 1 deletion src/common/ads/ad-break.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @class AdBreak
* @param {PKAdBreakOptions} options - Ad break data options.
*/
import { PKAdBreakOptions } from "../../types";
import { PKAdBreakOptions } from '../../types';

class AdBreak {
private readonly _type: string | undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/common/ads/ad.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PKAdOptions } from "../../types";
import { PKAdOptions } from '../../types';

/**
* @class Ad
Expand Down
4 changes: 2 additions & 2 deletions src/common/ads/prebid-manager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getLogger, Utils } from '@playkit-js/playkit-js';
import { KPAdPrebidConfig, KPPrebidConfig, DeferredPromise } from "../../types";
import { DeferredPromise, getLogger, Utils } from '@playkit-js/playkit-js';
import { KPAdPrebidConfig, KPPrebidConfig } from '../../types';

const AD_REQUEST_TIMEOUT = 4000;

Expand Down
2 changes: 1 addition & 1 deletion src/common/cast/remote-control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { PlayerSnapshot } from './player-snapshot';
import { CastEventType } from './cast-event-type';
import { RemoteAvailablePayload, RemoteConnectedPayload, RemoteDisconnectedPayload } from './remote-payload';
import { UIWrapper } from '../ui-wrapper';
import { SourcesConfig, PlaybackConfig } from "../../types";
import { SourcesConfig, PlaybackConfig } from '../../types';

/**
* @class RemoteControl
Expand Down
2 changes: 1 addition & 1 deletion src/common/cast/remote-player-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getLogger } from '@playkit-js/playkit-js';
import { RemoteControl } from './remote-control';
import { BaseRemotePlayer } from './base-remote-player';
import { KalturaPlayer } from '../../kaltura-player';
import { ClassConstructor } from "../../types";
import { ClassConstructor } from '../../types';

class RemotePlayerManager {
private static _registry: Map<string, ClassConstructor<BaseRemotePlayer>> = new Map();
Expand Down
5 changes: 1 addition & 4 deletions src/common/cast/remote-player-ui.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { Presets } from '@playkit-js/playkit-js-ui';

// TODO - should come from UI
class UIPreset {}
import { Presets, UIPreset } from '@playkit-js/playkit-js-ui';

/**
* @class RemotePlayerUI
Expand Down
2 changes: 1 addition & 1 deletion src/common/cast/remote-player.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FakeEvent, TextStyle, Track } from '@playkit-js/playkit-js';
import { ProviderMediaInfoObject } from '@playkit-js/playkit-js-providers';
import { RemoteSession } from './remote-session';
import { KPMediaConfig } from "../../types";
import { KPMediaConfig } from '../../types';

/**
* @interface IRemotePlayer
Expand Down
1 change: 0 additions & 1 deletion src/common/cast/remote-session.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* @class RemoteSession
* @param {string} id - Session ID.
Expand Down
7 changes: 5 additions & 2 deletions src/common/cast/text-style-convertor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,18 @@ class TextStyleConverter {
let digit = rgb[3];
digit = Math.round(digit * 100) / 100;
const alpha = Math.round(digit * 255);
hex += (alpha + 0x10000).toString(16).substr(-2).toUpperCase();
hex += (alpha + 0x10000)
.toString(16)
.substr(-2)
.toUpperCase();
} else {
hex += 'FF';
}
return hex.toUpperCase();
}

public static hexToRGB(hex: string): [number, number, number] {
const rgb: [number, number, number] = [] as unknown as [number, number, number];
const rgb: [number, number, number] = ([] as unknown) as [number, number, number];
hex = hex.slice(1);
const channels = hex.match(/.{1,2}/g);
for (let i = 0; i < 3; i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/common/controllers/controller-provider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PluginManager } from '../plugins';
import { IAdsPluginController, IAdsControllerProvider } from "../../types";
import { IAdsPluginController, IAdsControllerProvider } from '../../types';

/**
* Controller provider
Expand Down
2 changes: 1 addition & 1 deletion src/common/playlist/playlist-item.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Utils } from '@playkit-js/playkit-js';
import { PluginsConfig, SourcesConfig, KPPlaylistItemConfigObject } from "../../types";
import { PluginsConfig, SourcesConfig, KPPlaylistItemConfigObject } from '../../types';
const formats = ['hls', 'dash', 'progressive', 'image'];
/**
* @class PlaylistItem
Expand Down
2 changes: 1 addition & 1 deletion src/common/playlist/playlist-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PlaylistEventType } from './playlist-event-type';
import { Playlist } from './playlist';
import { PlaylistItem } from './playlist-item';
import { mergeProviderPluginsConfig } from '../utils/setup-helpers';
import { PlaylistOptions, PlaylistCountdownOptions, KalturaPlayerConfig, PluginsConfig,KPPlaylistObject, PlaylistConfigObject } from '../../types';
import { PlaylistOptions, PlaylistCountdownOptions, KalturaPlayerConfig, PluginsConfig, KPPlaylistObject, PlaylistConfigObject } from '../../types';

/**
* @class PlaylistManager
Expand Down
4 changes: 2 additions & 2 deletions src/common/plugins/plugins-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import evaluate from '../utils/evaluate';
import { getReferrer } from '../utils/kaltura-params';
import { Utils, getLogger } from '@playkit-js/playkit-js';
import { getServerUIConf } from '../utils/setup-helpers';
import { KalturaPlayerConfig, PluginsConfig } from "../../types";
import { KalturaPlayerConfig, PluginsConfig } from '../../types';

const logger = getLogger('PluginsConfig');

Expand Down Expand Up @@ -172,7 +172,7 @@ function _formatConfigString(config: string): any {
let configObj;
config = _sanitize(config);
try {
configObj = JSON.parse(config, function (key) {
configObj = JSON.parse(config, function(key) {
try {
return JSON.parse(this[key]);
} catch (e) {
Expand Down
1 change: 0 additions & 1 deletion src/common/storage/base-storage-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export class BaseStorageManager {
*/
public static init(className: string): void {
this._logger = getLogger(className);
//$FlowFixMe
BaseStorageHelper.getInstance().addManager(this);
}

Expand Down
4 changes: 2 additions & 2 deletions src/common/ui-wrapper.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { UIManager, Components } from '@playkit-js/playkit-js-ui';
import { Env, getLogger, Utils } from '@playkit-js/playkit-js';
import { KalturaPlayer } from '../kaltura-player';
import { UiConfig } from "../types";
import { KalturaPlayerConfig, KPUIAddComponent, KPUIRemoveComponent, PluginsConfig } from "../types";
import { UiConfig } from '../types';
import { KalturaPlayerConfig, KPUIAddComponent, KPUIRemoveComponent, PluginsConfig } from '../types';

/**
* The logger of the UIWrapper class.
Expand Down
2 changes: 1 addition & 1 deletion src/common/utils/external-stream-redirect-helper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Utils } from '@playkit-js/playkit-js';
import { KalturaPlayerConfig } from "../../types";
import { KalturaPlayerConfig } from '../../types';

/**
* JSONP handler function, returns the direct manifest uri.
Expand Down
2 changes: 1 addition & 1 deletion src/common/utils/media-capabilities.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getLogger } from '@playkit-js/playkit-js';
import { DRMSupportedObject, HEVCConfigObject, HEVCSupportedObject, MediaCapabilitiesObject, SupportedOptionsType } from "../../types";
import { DRMSupportedObject, HEVCConfigObject, HEVCSupportedObject, MediaCapabilitiesObject, SupportedOptionsType } from '../../types';

const CONTENT_TYPE_AVC_CODEC: string = 'video/mp4;codecs="avc1.42E01E"';
const DRM_SCHEME_LIST: Array<[string, string]> = [
Expand Down
2 changes: 1 addition & 1 deletion src/common/utils/viewability-manager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EventManager, Utils } from '@playkit-js/playkit-js';
import { ViewabilityConfig } from "../../types";
import { ViewabilityConfig } from '../../types';

/**
* A service class to observe viewability of elements in the view port.
Expand Down
2 changes: 1 addition & 1 deletion src/kaltura-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ export class KalturaPlayer extends FakeEventTarget {
uiComponents.push(...(plugin.getUIComponents() || []));
}
if (typeof plugin['getEngineDecorator'] === 'function') {
this._localPlayer.registerEngineDecoratorProvider(new EngineDecoratorProvider(plugin as unknown as IEngineDecoratorProvider));
this._localPlayer.registerEngineDecoratorProvider(new EngineDecoratorProvider((plugin as unknown) as IEngineDecoratorProvider));
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/ott/player-defaults.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Utils } from '@playkit-js/playkit-js';
import { getRedirectExternalStreamsHandler } from '../common/utils/external-stream-redirect-helper';
import { KalturaPlayerConfig } from "../types";
import { KalturaPlayerConfig } from '../types';

/**
* Sets the default analytics plugin for the ott player.
Expand Down
2 changes: 1 addition & 1 deletion src/ovp/player-defaults.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Env, Utils, MediaType } from '@playkit-js/playkit-js';
import { getRedirectExternalStreamsHandler } from '../common/utils/external-stream-redirect-helper';
import { KalturaPlayerConfig } from "../types";
import { KalturaPlayerConfig } from '../types';

/**
* Sets the default analytics plugin for the ovp player.
Expand Down
1 change: 0 additions & 1 deletion src/ovp/poster.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { THUMBNAIL_REGEX } from '../common/thumbnail-manager';
// import { DimensionsConfig } from '../types/dimensions-config';
import { ProviderMediaConfigSourcesObject } from '@playkit-js/playkit-js-providers';
import { PKDimensionsConfig, PKSourcesConfigObject } from '@playkit-js/playkit-js';

Expand Down
6 changes: 0 additions & 6 deletions src/types/utils/deferred-promise.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/types/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './class-constructor';
export * from './deferred-promise';
5 changes: 4 additions & 1 deletion tests/e2e/common/storage/storage-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ describe('StorageManager', (): any => {
it('should return config for volume', () => {
StorageWrapper._testForLocalStorage = (): any => (StorageWrapper._isLocalStorageAvailable = true);
sandbox.stub(StorageWrapper, 'getStorageSize').returns(1);
sandbox.stub(StorageWrapper, 'getItem').withArgs('volume').returns(1);
sandbox
.stub(StorageWrapper, 'getItem')
.withArgs('volume')
.returns(1);
LocalStorageManager.getStorageConfig().should.deep.equal({
playback: {
volume: 1
Expand Down
10 changes: 5 additions & 5 deletions tests/e2e/common/utils/viewability-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('ViewabilityManager', () => {

it('should create a viewability manager with an empty config and observe a div', (done) => {
viewabilityManager = new ViewabilityManager();
const handleVisibility = function (): any {
const handleVisibility = function(): any {
done();
};
viewabilityManager.observe(document.getElementById(targetId), handleVisibility);
Expand All @@ -31,18 +31,18 @@ describe('ViewabilityManager', () => {
playerThreshold: 20
};
viewabilityManager = new ViewabilityManager(viewabilityConfig);
const handleVisibility = function (): any {
const handleVisibility = function(): any {
done();
};
viewabilityManager.observe(document.getElementById(targetId), handleVisibility);
});

it('should observe twice the same div and check both listeners are invoked', (done) => {
viewabilityManager = new ViewabilityManager();
const handleVisibility1 = function (): any {
const handleVisibility1 = function(): any {
viewabilityManager.observe(document.getElementById(targetId), handleVisibility2);
};
const handleVisibility2 = function (): any {
const handleVisibility2 = function(): any {
done();
viewabilityManager.unObserve(document.getElementById(targetId), handleVisibility2);
};
Expand All @@ -51,7 +51,7 @@ describe('ViewabilityManager', () => {

it('should check types TAB and VIEWPORT were sent correct', (done) => {
viewabilityManager = new ViewabilityManager();
const handleVisibility = function (visible, viewabilityType): any {
const handleVisibility = function(visible, viewabilityType): any {
if (viewabilityType === ViewabilityType.VIEWPORT) {
viewabilityManager._targetsObserved.getAll()[0].lastVisible = true;
viewabilityManager._handleTabVisibilityChange();
Expand Down
6 changes: 4 additions & 2 deletions tests/e2e/mock-data/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ const MediaConfig = {
hls: [
{
id: '0_wifqaipd_861,applehttp',
url: 'http://qa-apache-php7.dev.kaltura.com/p/1091/sp/109100/playManifest/entryId/0_wifqaipd/protocol/http/format/applehttp/flavorIds/0_h65mfj7f,0_3flmvnwc,0_m131krws,0_5407xm9j,0_xcrwyk2n/a.m3u8?uiConfId=15215933',
url:
'http://qa-apache-php7.dev.kaltura.com/p/1091/sp/109100/playManifest/entryId/0_wifqaipd/protocol/http/format/applehttp/flavorIds/0_h65mfj7f,0_3flmvnwc,0_m131krws,0_5407xm9j,0_xcrwyk2n/a.m3u8?uiConfId=15215933',
mimetype: 'application/x-mpegURL'
}
],
dash: [
{
id: '0_wifqaipd_911,mpegdash',
url: 'http://qa-apache-php7.dev.kaltura.com/p/1091/sp/109100/playManifest/entryId/0_wifqaipd/protocol/http/format/mpegdash/flavorIds/0_m131krws,0_5407xm9j,0_xcrwyk2n/a.mpd?uiConfId=15215933',
url:
'http://qa-apache-php7.dev.kaltura.com/p/1091/sp/109100/playManifest/entryId/0_wifqaipd/protocol/http/format/mpegdash/flavorIds/0_m131krws,0_5407xm9j,0_xcrwyk2n/a.mpd?uiConfId=15215933',
mimetype: 'application/dash+xml'
}
],
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/mock-data/playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ const playlistByConfig = {
hls: [
{
mimetype: 'application/x-mpegURL',
url: 'http://qa-apache-php7.dev.kaltura.com/p/1091/sp/109100/playManifest/entryId/0_fu4ifhie/protocol/http/format/applehttp/flavorIds/0_wbawecj0,0_cj2odpyt,0_uj45vim0,0_xlpm7btj,0_6p25la0i,0_cmq5aigy/a.m3u8'
url:
'http://qa-apache-php7.dev.kaltura.com/p/1091/sp/109100/playManifest/entryId/0_fu4ifhie/protocol/http/format/applehttp/flavorIds/0_wbawecj0,0_cj2odpyt,0_uj45vim0,0_xlpm7btj,0_6p25la0i,0_cmq5aigy/a.m3u8'
}
]
}
Expand Down
5 changes: 4 additions & 1 deletion tests/e2e/setup.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ describe('setup', () => {
backgroundOpacity: 1,
fontEdge: []
});
sandbox.stub(LocalStorageManager, 'getItem').withArgs('textStyle').returns(textStyle);
sandbox
.stub(LocalStorageManager, 'getItem')
.withArgs('textStyle')
.returns(textStyle);
kalturaPlayer = setup(config);
kalturaPlayer.textStyle.should.deep.equal(textStyle);
});
Expand Down
3 changes: 1 addition & 2 deletions tests/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import chai from 'chai';
import sinonChai from 'sinon-chai';
import sinon from 'sinon/pkg/sinon-esm';
// import 'promise-polyfill/src/polyfill';
// eslint-disable-next-line no-undef

chai.should();
chai.use(sinonChai);
global.chai = chai;
Expand Down
Loading

0 comments on commit 1ff11d2

Please sign in to comment.