Skip to content

Commit

Permalink
Feature/lint enforce indent (#3921)
Browse files Browse the repository at this point in the history
* Enforce specific indent in linting config

* Fix linting errors

* Fix linting errors

* Fix linting errors
  • Loading branch information
dsilhavy authored Apr 14, 2022
1 parent 1a64423 commit 2aad3e7
Show file tree
Hide file tree
Showing 32 changed files with 408 additions and 318 deletions.
53 changes: 30 additions & 23 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
{
"env": {
"browser": true,
"es6": true,
"mocha": true,
"node": true
},
"globals": {
"dashjs": true,
"WebKitMediaSource": true,
"MediaSource": true,
"WebKitMediaKeys": true,
"MSMediaKeys": true,
"MediaKeys": true
},
"parser": "babel-eslint",
"rules": {
"no-caller": 2,
"no-undef": 2,
"no-unused-vars": 2,
"no-use-before-define": 0,
"strict": 0,
"no-loop-func": 0
}
"env": {
"browser": true,
"es6": true,
"mocha": true,
"node": true
},
"globals": {
"dashjs": true,
"WebKitMediaSource": true,
"MediaSource": true,
"WebKitMediaKeys": true,
"MSMediaKeys": true,
"MediaKeys": true
},
"parser": "babel-eslint",
"rules": {
"no-caller": 2,
"no-undef": 2,
"no-unused-vars": 2,
"no-use-before-define": 0,
"strict": 0,
"no-loop-func": 0,
"indent": [
"error",
4,
{
"SwitchCase": 1
}
]
}
}
8 changes: 5 additions & 3 deletions src/dash/DashAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,10 @@ function DashAdapter() {
* @memberOf module:DashAdapter
* @instance
*/
function getProducerReferenceTimes(streamInfo, mediaInfo) {
function getProducerReferenceTimes(streamInfo, mediaInfo) {
let id, realAdaptation;

const selectedVoPeriod = getPeriodForStreamInfo(streamInfo, voPeriods);
const selectedVoPeriod = getPeriodForStreamInfo(streamInfo, voPeriods);
id = mediaInfo ? mediaInfo.id : null;

if (voPeriods.length > 0 && selectedVoPeriod) {
Expand Down Expand Up @@ -1052,7 +1052,9 @@ function DashAdapter() {
const keyIds = mediaInfo.contentProtection.map(cp => dashManifestModel.getKID(cp)).filter(kid => kid !== null);
if (keyIds.length) {
const keyId = keyIds[0];
mediaInfo.contentProtection.forEach(cp => { cp.keyId = keyId; });
mediaInfo.contentProtection.forEach(cp => {
cp.keyId = keyId;
});
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/dash/models/DashManifestModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -712,18 +712,18 @@ function DashManifestModel() {
voPeriod = new Period();
voPeriod.start = realPeriod.start;
}
// If the @start attribute is absent, but the previous Period
// element contains a @duration attribute then then this new
// Period is also a regular Period. The start time of the new
// Period PeriodStart is the sum of the start time of the previous
// Period PeriodStart and the value of the attribute @duration
// If the @start attribute is absent, but the previous Period
// element contains a @duration attribute then then this new
// Period is also a regular Period. The start time of the new
// Period PeriodStart is the sum of the start time of the previous
// Period PeriodStart and the value of the attribute @duration
// of the previous Period.
else if (realPreviousPeriod !== null && realPreviousPeriod.hasOwnProperty(DashConstants.DURATION) && voPreviousPeriod !== null) {
voPeriod = new Period();
voPeriod.start = parseFloat((voPreviousPeriod.start + voPreviousPeriod.duration).toFixed(5));
}
// If (i) @start attribute is absent, and (ii) the Period element
// is the first in the MPD, and (iii) the MPD@type is 'static',
// If (i) @start attribute is absent, and (ii) the Period element
// is the first in the MPD, and (iii) the MPD@type is 'static',
// then the PeriodStart time shall be set to zero.
else if (i === 0 && !isDynamic) {
voPeriod = new Period();
Expand Down
3 changes: 1 addition & 2 deletions src/dash/utils/SegmentsUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ export function replaceTokenForTemplate(url, token, value) {
}
}

function getSegment(representation, duration, presentationStartTime, mediaStartTime,
timelineConverter, presentationEndTime, isDynamic, index) {
function getSegment(representation, duration, presentationStartTime, mediaStartTime, timelineConverter, presentationEndTime, isDynamic, index) {
let seg = new Segment();

seg.representation = representation;
Expand Down
4 changes: 2 additions & 2 deletions src/dash/vo/ProducerReferenceTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* @class
* @ignore
*/
class ProducerReferenceTime {
class ProducerReferenceTime {
constructor() {
this.id = null;
this.inband = false;
Expand All @@ -44,4 +44,4 @@
}
}

export default ProducerReferenceTime;
export default ProducerReferenceTime;
2 changes: 1 addition & 1 deletion src/mss/MssFragmentMoovProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
import MssErrors from './errors/MssErrors';
import MssErrors from './errors/MssErrors';

/**
* @module MssFragmentMoovProcessor
Expand Down
5 changes: 3 additions & 2 deletions src/mss/errors/MssErrors.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
import ErrorsBase from '../../core/errors/ErrorsBase';

/**
* @class
*
*/
class MssErrors extends ErrorsBase {
constructor () {
constructor() {
super();
/**
* Error code returned when no tfrf box is detected in MSS live stream
Expand All @@ -52,4 +53,4 @@ class MssErrors extends ErrorsBase {
}

let mssErrors = new MssErrors();
export default mssErrors;
export default mssErrors;
95 changes: 51 additions & 44 deletions src/offline/OfflineDownload.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ function OfflineDownload(config) {
return manifestId;
}

function getOfflineUrl () {
function getOfflineUrl() {
return _offlineURL;
}

function getManifestUrl () {
function getManifestUrl() {
return _manifestURL;
}

function getStatus () {
function getStatus() {
return _status;
}

Expand Down Expand Up @@ -177,7 +177,10 @@ function OfflineDownload(config) {
if (!e.error && manifestId !== null) {
_status = OfflineConstants.OFFLINE_STATUS_STARTED;
offlineStoreController.setDownloadingStatus(manifestId, _status).then(function () {
eventBus.trigger(events.OFFLINE_RECORD_STARTED, { id: manifestId, message: 'Downloading started for this stream !' });
eventBus.trigger(events.OFFLINE_RECORD_STARTED, {
id: manifestId,
message: 'Downloading started for this stream !'
});
});
} else {
_status = OfflineConstants.OFFLINE_STATUS_ERROR;
Expand Down Expand Up @@ -234,10 +237,13 @@ function OfflineDownload(config) {
if (!e.error && manifestId !== null) {
_status = OfflineConstants.OFFLINE_STATUS_FINISHED;
offlineStoreController.setDownloadingStatus(manifestId, _status)
.then(function () {
eventBus.trigger(events.OFFLINE_RECORD_FINISHED, { id: manifestId, message: 'Downloading has been successfully completed for this stream !' });
resetDownload();
});
.then(function () {
eventBus.trigger(events.OFFLINE_RECORD_FINISHED, {
id: manifestId,
message: 'Downloading has been successfully completed for this stream !'
});
resetDownload();
});
} else {
_status = OfflineConstants.OFFLINE_STATUS_ERROR;
errHandler.error({
Expand All @@ -263,15 +269,15 @@ function OfflineDownload(config) {
_indexDBManifestParser.parse(_xmlManifest, _representationsToUpdate).then(function (parsedManifest) {
if (parsedManifest !== null && manifestId !== null) {
offlineStoreController.getManifestById(manifestId)
.then((item) => {
item.manifest = parsedManifest;
return updateOfflineManifest(item);
})
.then( function () {
for (let i = 0, ln = _streams.length; i < ln; i++) {
_streams[i].startOfflineStreamProcessors();
}
});
.then((item) => {
item.manifest = parsedManifest;
return updateOfflineManifest(item);
})
.then(function () {
for (let i = 0, ln = _streams.length; i < ln; i++) {
_streams[i].startOfflineStreamProcessors();
}
});
} else {
throw 'falling parsing offline manifest';
}
Expand Down Expand Up @@ -466,15 +472,15 @@ function OfflineDownload(config) {
let rep = getSelectedRepresentations(mediaInfos);

offlineStoreController.saveSelectedRepresentations(manifestId, rep)
.then(() => {
return createFragmentStore(manifestId);
})
.then(() => {
return generateOfflineManifest(rep);
})
.then(function () {
initializeAllMediasInfoList(rep);
});
.then(() => {
return createFragmentStore(manifestId);
})
.then(() => {
return generateOfflineManifest(rep);
})
.then(function () {
initializeAllMediasInfoList(rep);
});
} catch (err) {
_status = OfflineConstants.OFFLINE_STATUS_ERROR;
errHandler.error({
Expand Down Expand Up @@ -507,12 +513,12 @@ function OfflineDownload(config) {
return _indexDBManifestParser.parse(_xmlManifest).then(function (parsedManifest) {
if (parsedManifest !== null) {
return offlineStoreController.getManifestById(manifestId)
.then((item) => {
item.originalURL = _manifest.url;
item.originalManifest = _xmlManifest;
item.manifest = parsedManifest;
return updateOfflineManifest(item);
});
.then((item) => {
item.originalURL = _manifest.url;
item.originalManifest = _xmlManifest;
item.manifest = parsedManifest;
return updateOfflineManifest(item);
});
} else {
return Promise.reject('falling parsing offline manifest');
}
Expand Down Expand Up @@ -572,20 +578,21 @@ function OfflineDownload(config) {
let selectedRepresentations;

offlineStoreController.getManifestById(manifestId)
.then((item) => {
let parser = DashParser(context).create({debug: debug});
_manifest = parser.parse(item.originalManifest);
.then((item) => {
let parser = DashParser(context).create({ debug: debug });
_manifest = parser.parse(item.originalManifest);

composeStreams(_manifest);
composeStreams(_manifest);

selectedRepresentations = item.selected;
selectedRepresentations = item.selected;

eventBus.trigger(events.STREAMS_COMPOSED);
eventBus.trigger(events.STREAMS_COMPOSED);

return createFragmentStore(manifestId);
}). then(() => {
initializeAllMediasInfoList(selectedRepresentations);
});
return createFragmentStore(manifestId);
})
.then(() => {
initializeAllMediasInfoList(selectedRepresentations);
});
}

/**
Expand Down Expand Up @@ -613,8 +620,8 @@ function OfflineDownload(config) {
}

function onError(e) {
if ( e.error.code === OfflineErrors.INDEXEDDB_QUOTA_EXCEED_ERROR ||
e.error.code === OfflineErrors.INDEXEDDB_INVALID_STATE_ERROR ) {
if (e.error.code === OfflineErrors.INDEXEDDB_QUOTA_EXCEED_ERROR ||
e.error.code === OfflineErrors.INDEXEDDB_INVALID_STATE_ERROR) {
stopDownload();
}
}
Expand Down
Loading

0 comments on commit 2aad3e7

Please sign in to comment.