Skip to content

Commit

Permalink
Add import/order eslint rules and run npm run lint:fix (#6378)
Browse files Browse the repository at this point in the history
  • Loading branch information
robwalch authored Oct 10, 2024
1 parent 50ac389 commit 2299042
Show file tree
Hide file tree
Showing 108 changed files with 833 additions and 849 deletions.
27 changes: 27 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,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 @@ -100,6 +124,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
26 changes: 12 additions & 14 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
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 InterstitialsController from './controller/interstitials-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 InterstitialsController from './controller/interstitials-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 @@ -35,6 +30,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
Original file line number Diff line number Diff line change
@@ -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
42 changes: 19 additions & 23 deletions src/controller/audio-stream-controller.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,44 @@
import BaseStreamController, { State } from './base-stream-controller';
import { Events } from '../events';
import { findFragWithCC, findNearestWithCC } from './fragment-finders';
import { FragmentState } from './fragment-tracker';
import { Level } from '../types/level';
import { PlaylistContextType, PlaylistLevelType } from '../types/loader';
import {
Fragment,
ElementaryStreamTypes,
Part,
MediaFragment,
} 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 { findFragWithCC, findNearestWithCC } from './fragment-finders';
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 { Fragment, MediaFragment, 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,
BufferCodecsData,
BufferCreatedData,
BufferFlushedData,
InitPTSFoundData,
BufferFlushingData,
ErrorData,
FragBufferedData,
FragLoadedData,
FragLoadingData,
FragParsingMetadataData,
FragParsingUserdataData,
FragBufferedData,
ErrorData,
BufferFlushingData,
BufferCodecsData,
FragLoadingData,
InitPTSFoundData,
LevelLoadedData,
MediaDetachingData,
TrackLoadedData,
} from '../types/events';
import type { MediaPlaylist } from '../types/media-playlist';
import type { TrackSet } from '../types/track';
import type { TransmuxerResult } from '../types/transmuxer';

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

Expand Down
16 changes: 8 additions & 8 deletions src/controller/audio-track-controller.ts
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
56 changes: 29 additions & 27 deletions src/controller/base-stream-controller.ts
Original file line number Diff line number Diff line change
@@ -1,57 +1,59 @@
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, MediaFragment, 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, MediaFragment, Part } from '../loader/fragment';
import type {
FragmentLoadProgressCallback,
LoadError,
} from '../loader/fragment-loader';
import KeyLoader from '../loader/key-loader';
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,
MediaDetachingData,
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
Loading

0 comments on commit 2299042

Please sign in to comment.