Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidy import statements with linter rules #6378

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions .eslintrc.js
Expand Up @@ -85,6 +85,30 @@ module.exports = {
'no-unused-vars': 0,
'no-undef': 0,
'no-use-before-define': 'off',
'import/order': [
'warn',
{
alphabetize: {
order: 'asc',
},
groups: [
'builtin',
'external',
'internal',
['sibling', 'index'],
'parent',
'type',
],
'newlines-between': 'never',
},
],
'sort-imports': [
'error',
{
ignoreCase: true,
ignoreDeclarationSort: true,
},
],
'@typescript-eslint/no-unused-vars': [
'warn',
{
Expand All @@ -99,6 +123,9 @@ module.exports = {
objectLiteralTypeAssertions: 'never',
},
],
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-import-type-side-effects': 'error',
'@typescript-eslint/no-restricted-imports': 'error',
},
},
],
Expand Down
24 changes: 11 additions & 13 deletions src/config.ts
@@ -1,27 +1,22 @@
import AbrController from './controller/abr-controller';
import AudioStreamController from './controller/audio-stream-controller';
import AudioTrackController from './controller/audio-track-controller';
import { SubtitleStreamController } from './controller/subtitle-stream-controller';
import SubtitleTrackController from './controller/subtitle-track-controller';
import BufferController from './controller/buffer-controller';
import { TimelineController } from './controller/timeline-controller';
import CapLevelController from './controller/cap-level-controller';
import FPSController from './controller/fps-controller';
import EMEController, {
MediaKeySessionContext,
} from './controller/eme-controller';
import CMCDController from './controller/cmcd-controller';
import ContentSteeringController from './controller/content-steering-controller';
import EMEController from './controller/eme-controller';
import ErrorController from './controller/error-controller';
import XhrLoader from './utils/xhr-loader';
import FetchLoader, { fetchSupported } from './utils/fetch-loader';
import FPSController from './controller/fps-controller';
import { SubtitleStreamController } from './controller/subtitle-stream-controller';
import SubtitleTrackController from './controller/subtitle-track-controller';
import { TimelineController } from './controller/timeline-controller';
import Cues from './utils/cues';
import FetchLoader, { fetchSupported } from './utils/fetch-loader';
import { requestMediaKeySystemAccess } from './utils/mediakeys-helper';

import XhrLoader from './utils/xhr-loader';
import type { MediaKeySessionContext } from './controller/eme-controller';
import type Hls from './hls';
import type { CuesInterface } from './utils/cues';
import type { ILogger } from './utils/logger';
import type { MediaKeyFunc, KeySystems } from './utils/mediakeys-helper';
import type {
FragmentLoaderContext,
Loader,
Expand All @@ -34,6 +29,9 @@ import type {
SubtitleSelectionOption,
VideoSelectionOption,
} from './types/media-playlist';
import type { CuesInterface } from './utils/cues';
import type { ILogger } from './utils/logger';
import type { KeySystems, MediaKeyFunc } from './utils/mediakeys-helper';

export type ABRControllerConfig = {
abrEwmaFastLive: number;
Expand Down
24 changes: 12 additions & 12 deletions src/controller/abr-controller.ts
@@ -1,35 +1,35 @@
import EwmaBandWidthEstimator from '../utils/ewma-bandwidth-estimator';
import { Events } from '../events';
import { ErrorDetails } from '../errors';
import { Events } from '../events';
import { PlaylistLevelType } from '../types/loader';
import EwmaBandWidthEstimator from '../utils/ewma-bandwidth-estimator';
import { Logger } from '../utils/logger';
import {
SUPPORTED_INFO_DEFAULT,
getMediaDecodingInfoPromise,
requiresMediaCapabilitiesDecodingInfo,
SUPPORTED_INFO_DEFAULT,
} from '../utils/mediacapabilities-helper';
import {
type AudioTracksByGroup,
type CodecSetTier,
getAudioTracksByGroup,
getCodecTiers,
getStartCodecTier,
type AudioTracksByGroup,
type CodecSetTier,
} from '../utils/rendition-helper';
import type Hls from '../hls';
import type { Fragment } from '../loader/fragment';
import type { Part } from '../loader/fragment';
import type { Level, VideoRange } from '../types/level';
import type { LoaderStats } from '../types/loader';
import type Hls from '../hls';
import type { AbrComponentAPI } from '../types/component-api';
import type {
FragLoadingData,
FragLoadedData,
ErrorData,
FragBufferedData,
FragLoadedData,
FragLoadingData,
LevelLoadedData,
LevelSwitchingData,
ManifestLoadingData,
ErrorData,
} from '../types/events';
import type { AbrComponentAPI } from '../types/component-api';
import type { Level, VideoRange } from '../types/level';
import type { LoaderStats } from '../types/loader';

class AbrController extends Logger implements AbrComponentAPI {
protected hls: Hls;
Expand Down
38 changes: 20 additions & 18 deletions src/controller/audio-stream-controller.ts
@@ -1,41 +1,43 @@
import BaseStreamController, { State } from './base-stream-controller';
import { Events } from '../events';
import { Bufferable, BufferHelper } from '../utils/buffer-helper';
import { fragmentWithinToleranceTest } from './fragment-finders';
import { FragmentState } from './fragment-tracker';
import { Level } from '../types/level';
import { PlaylistContextType, PlaylistLevelType } from '../types/loader';
import { Fragment, ElementaryStreamTypes, Part } from '../loader/fragment';
import ChunkCache from '../demux/chunk-cache';
import TransmuxerInterface from '../demux/transmuxer-interface';
import { ErrorDetails } from '../errors';
import { Events } from '../events';
import { ElementaryStreamTypes } from '../loader/fragment';
import { Level } from '../types/level';
import { PlaylistContextType, PlaylistLevelType } from '../types/loader';
import { ChunkMetadata } from '../types/transmuxer';
import { fragmentWithinToleranceTest } from './fragment-finders';
import { BufferHelper } from '../utils/buffer-helper';
import { alignMediaPlaylistByPDT } from '../utils/discontinuities';
import { mediaAttributesIdentical } from '../utils/media-option-attributes';
import { ErrorDetails } from '../errors';
import type { NetworkComponentAPI } from '../types/component-api';
import type Hls from '../hls';
import type { FragmentTracker } from './fragment-tracker';
import type Hls from '../hls';
import type { Fragment, Part } from '../loader/fragment';
import type KeyLoader from '../loader/key-loader';
import type { TransmuxerResult } from '../types/transmuxer';
import type { LevelDetails } from '../loader/level-details';
import type { TrackSet } from '../types/track';
import type { NetworkComponentAPI } from '../types/component-api';
import type {
BufferCreatedData,
AudioTracksUpdatedData,
AudioTrackSwitchingData,
LevelLoadedData,
TrackLoadedData,
BufferAppendingData,
BufferCreatedData,
BufferFlushedData,
InitPTSFoundData,
BufferFlushingData,
ErrorData,
FragBufferedData,
FragLoadedData,
FragParsingMetadataData,
FragParsingUserdataData,
FragBufferedData,
ErrorData,
BufferFlushingData,
InitPTSFoundData,
LevelLoadedData,
TrackLoadedData,
} from '../types/events';
import type { MediaPlaylist } from '../types/media-playlist';
import type { TrackSet } from '../types/track';
import type { TransmuxerResult } from '../types/transmuxer';
import type { Bufferable } from '../utils/buffer-helper';

const TICK_INTERVAL = 100; // how often to tick in ms

Expand Down
16 changes: 8 additions & 8 deletions src/controller/audio-track-controller.ts
@@ -1,6 +1,6 @@
import BasePlaylistController from './base-playlist-controller';
import { ErrorDetails, ErrorTypes } from '../errors';
import { Events } from '../events';
import { ErrorTypes, ErrorDetails } from '../errors';
import { PlaylistContextType } from '../types/loader';
import { mediaAttributesIdentical } from '../utils/media-option-attributes';
import {
Expand All @@ -11,18 +11,18 @@ import {
} from '../utils/rendition-helper';
import type Hls from '../hls';
import type {
AudioSelectionOption,
MediaPlaylist,
} from '../types/media-playlist';
import type { HlsUrlParameters } from '../types/level';
import type {
ManifestParsedData,
AudioTrackLoadedData,
AudioTracksUpdatedData,
ErrorData,
LevelLoadingData,
AudioTrackLoadedData,
LevelSwitchingData,
ManifestParsedData,
} from '../types/events';
import type { HlsUrlParameters } from '../types/level';
import type {
AudioSelectionOption,
MediaPlaylist,
} from '../types/media-playlist';

class AudioTrackController extends BasePlaylistController {
private tracks: MediaPlaylist[] = [];
Expand Down
12 changes: 6 additions & 6 deletions src/controller/base-playlist-controller.ts
@@ -1,23 +1,23 @@
import type Hls from '../hls';
import type { NetworkComponentAPI } from '../types/component-api';
import { NetworkErrorAction } from './error-controller';
import {
getSkipValue,
HlsSkip,
HlsUrlParameters,
type Level,
} from '../types/level';
import { computeReloadInterval, mergeDetails } from '../utils/level-helper';
import type { ErrorData } from '../types/events';
import { getRetryDelay, isTimeoutError } from '../utils/error-helper';
import { NetworkErrorAction } from './error-controller';
import { computeReloadInterval, mergeDetails } from '../utils/level-helper';
import { Logger } from '../utils/logger';
import type Hls from '../hls';
import type { LevelDetails } from '../loader/level-details';
import type { MediaPlaylist } from '../types/media-playlist';
import type { NetworkComponentAPI } from '../types/component-api';
import type { ErrorData } from '../types/events';
import type {
AudioTrackLoadedData,
LevelLoadedData,
TrackLoadedData,
} from '../types/events';
import type { MediaPlaylist } from '../types/media-playlist';

export default class BasePlaylistController
extends Logger
Expand Down
58 changes: 30 additions & 28 deletions src/controller/base-stream-controller.ts
@@ -1,56 +1,58 @@
import TaskLoop from '../task-loop';
import { NetworkErrorAction } from './error-controller';
import {
findFragmentByPDT,
findFragmentByPTS,
findFragWithCC,
} from './fragment-finders';
import { FragmentState } from './fragment-tracker';
import { Bufferable, BufferHelper, BufferInfo } from '../utils/buffer-helper';
import { Events } from '../events';
import Decrypter from '../crypt/decrypter';
import { ErrorDetails, ErrorTypes } from '../errors';
import { Events } from '../events';
import FragmentLoader from '../loader/fragment-loader';
import TaskLoop from '../task-loop';
import { PlaylistLevelType } from '../types/loader';
import { ChunkMetadata } from '../types/transmuxer';
import { appendUint8Array } from '../utils/mp4-tools';
import { BufferHelper } from '../utils/buffer-helper';
import { alignStream } from '../utils/discontinuities';
import {
isFullSegmentEncryption,
getAesModeFromFullSegmentMethod,
isFullSegmentEncryption,
} from '../utils/encryption-methods-util';
import {
findFragmentByPDT,
findFragmentByPTS,
findFragWithCC,
} from './fragment-finders';
import { getRetryDelay } from '../utils/error-helper';
import {
findPart,
getFragmentWithSN,
getPartWith,
updateFragPTSDTS,
} from '../utils/level-helper';
import TransmuxerInterface from '../demux/transmuxer-interface';
import { Fragment, Part } from '../loader/fragment';
import FragmentLoader, {
import { appendUint8Array } from '../utils/mp4-tools';
import TimeRanges from '../utils/time-ranges';
import type { FragmentTracker } from './fragment-tracker';
import type { HlsConfig } from '../config';
import type TransmuxerInterface from '../demux/transmuxer-interface';
import type Hls from '../hls';
import type { Fragment, Part } from '../loader/fragment';
import type {
FragmentLoadProgressCallback,
LoadError,
} from '../loader/fragment-loader';
import KeyLoader from '../loader/key-loader';
import { LevelDetails } from '../loader/level-details';
import Decrypter from '../crypt/decrypter';
import TimeRanges from '../utils/time-ranges';
import { PlaylistLevelType } from '../types/loader';
import { getRetryDelay } from '../utils/error-helper';
import { NetworkErrorAction } from './error-controller';
import type KeyLoader from '../loader/key-loader';
import type { LevelDetails } from '../loader/level-details';
import type { SourceBufferName } from '../types/buffer';
import type { NetworkComponentAPI } from '../types/component-api';
import type {
BufferAppendingData,
BufferFlushingData,
ErrorData,
FragLoadedData,
PartsLoadedData,
KeyLoadedData,
MediaAttachedData,
BufferFlushingData,
ManifestLoadedData,
MediaAttachedData,
PartsLoadedData,
} from '../types/events';
import type { FragmentTracker } from './fragment-tracker';
import type { Level } from '../types/level';
import type { RemuxedTrack } from '../types/remuxer';
import type Hls from '../hls';
import type { HlsConfig } from '../config';
import type { NetworkComponentAPI } from '../types/component-api';
import type { SourceBufferName } from '../types/buffer';
import type { Bufferable, BufferInfo } from '../utils/buffer-helper';
import type { RationalTimestamp } from '../utils/timescale-conversion';

type ResolveFragLoaded = (FragLoadedEndData) => void;
Expand Down