Skip to content

Commit

Permalink
Only allow one statement per line.
Browse files Browse the repository at this point in the history
With the new style rule, we cannot have two statements on the same line.
So we can no longer have an "if" on a single line and we cannot have
an arrow function with a body on the same line as when it is used.
This is mostly a manual change.

Change-Id: I2285202dd5ecbad764308bc725e6d317ff2ee7f0
  • Loading branch information
TheModMaker committed May 13, 2019
1 parent 984bb6f commit 0dd6407
Show file tree
Hide file tree
Showing 87 changed files with 990 additions and 395 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,14 @@ module.exports = {
"block-spacing": ["error", "always"],
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
"lines-between-class-members": "error",
"max-statements-per-line": ["error", {"max": 1}],
"new-parens": "error",
"no-mixed-operators": ["error", {
"groups": [["&", "|", "^", "~", "<<", ">>", ">>>", "&&", "||"]],
"allowSamePrecedence": false,
}],
"no-whitespace-before-property": "error",
"nonblock-statement-body-position": ["error", "below"],
"operator-assignment": "error",
// }}}

Expand Down
4 changes: 3 additions & 1 deletion demo/cast_receiver/receiver_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ ShakaReceiver.prototype.init = function() {
*/
ShakaReceiver.prototype.appDataCallback_ = function(appData) {
// appData is null if we start the app without any media loaded.
if (!appData) return;
if (!appData) {
return;
}

const asset = ShakaDemoAssetInfo.fromJSON(appData['asset']);
asset.applyFilters(this.player_.getNetworkingEngine());
Expand Down
4 changes: 3 additions & 1 deletion demo/common/asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,9 @@ const ShakaDemoAssetInfo = class {
* @private
*/
addLicenseRequestHeaders_(headers, requestType, request) {
if (requestType != shaka.net.NetworkingEngine.RequestType.LICENSE) return;
if (requestType != shaka.net.NetworkingEngine.RequestType.LICENSE) {
return;
}

// Add these to the existing headers. Do not clobber them!
// For PlayReady, there will already be headers in the request.
Expand Down
20 changes: 15 additions & 5 deletions demo/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,9 @@ class ShakaDemoConfig {

// shaka.log is not set if logging isn't enabled.
// I.E. if using the release version of shaka.
if (!shaka['log']) return;
if (!shaka['log']) {
return;
}

// Access shaka.log using bracket syntax because shaka.log is not exported.
// Exporting the logging methods proved to be a bad solution, both in terms
Expand Down Expand Up @@ -373,10 +375,18 @@ class ShakaDemoConfig {
this.addSelectInput_('Log Level', logLevels, onChange);
const input = this.latestInput_.input();
switch (shaka['log']['currentLevel']) {
case Level['DEBUG']: input.value = 'debug'; break;
case Level['V2']: input.value = 'vv'; break;
case Level['V1']: input.value = 'v'; break;
default: input.value = 'info'; break;
case Level['DEBUG']:
input.value = 'debug';
break;
case Level['V2']:
input.value = 'vv';
break;
case Level['V1']:
input.value = 'v';
break;
default:
input.value = 'info';
break;
}
}

Expand Down
4 changes: 3 additions & 1 deletion demo/demo_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ ShakaDemoUtils.runThroughHashParams = (callback, config) => {
for (const key in object) {
let hashName = key;
const configName = accumulated + key;
if (overridden.includes(configName)) continue;
if (overridden.includes(configName)) {
continue;
}
if (collisions.includes(key)) {
hashName = configName;
}
Expand Down
4 changes: 3 additions & 1 deletion demo/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class ShakaDemoInput {

/** @private {!Element} */
this.input_ = document.createElement(inputType);
this.input_.onchange = () => { onChange(this.input_); };
this.input_.onchange = () => {
onChange(this.input_);
};
this.input_.id = ShakaDemoInput.generateNewId_('input');
this.container_.appendChild(this.input_);

Expand Down
20 changes: 15 additions & 5 deletions demo/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ class ShakaDemoMain {
// Exception to the exceptions we catch: ChromeVox (screenreader) always
// throws an error as of Chrome 73. Screen these out since they are
// unrelated to our application and we can't control them.
if (event.message.includes('cvox.ApiImplementation')) return;
if (event.message.includes('cvox.ApiImplementation')) {
return;
}

this.onError_(/** @type {!shaka.util.Error} */ (event.error));
});
Expand Down Expand Up @@ -976,10 +978,18 @@ class ShakaDemoMain {
// if it's different from this default.
if (shaka.log && shaka.log.currentLevel != shaka.log.MAX_LOG_LEVEL) {
switch (shaka.log.currentLevel) {
case shaka.log.Level.INFO: params.push('info'); break;
case shaka.log.Level.DEBUG: params.push('debug'); break;
case shaka.log.Level.V2: params.push('vv'); break;
case shaka.log.Level.V1: params.push('v'); break;
case shaka.log.Level.INFO:
params.push('info');
break;
case shaka.log.Level.DEBUG:
params.push('debug');
break;
case shaka.log.Level.V2:
params.push('vv');
break;
case shaka.log.Level.V1:
params.push('v');
break;
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/cast/cast_proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ shaka.cast.CastProxy.prototype.playerProxyGet_ = function(name) {
}

if (name == 'getMediaElement') {
return function() { return this.videoProxy_; }.bind(this);
return () => this.videoProxy_;
}

if (name == 'getSharedConfiguration') {
Expand Down
4 changes: 3 additions & 1 deletion lib/cast/cast_receiver.js
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,9 @@ shaka.cast.CastReceiver.prototype.sendAsyncComplete_ =
shaka.cast.CastReceiver.prototype.sendMessage_ =
function(message, bus, senderId) {
// Cuts log spam when debugging the receiver UI in Chrome.
if (!this.isConnected_) return;
if (!this.isConnected_) {
return;
}

const serialized = shaka.cast.CastUtils.serialize(message);
if (senderId) {
Expand Down
4 changes: 3 additions & 1 deletion lib/cast/cast_sender.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,9 @@ shaka.cast.CastSender.prototype.onMessageReceived_ =
delete this.asyncCallPromises_[id];

goog.asserts.assert(p, 'Unexpected async id');
if (!p) break;
if (!p) {
break;
}

if (error) {
// This is a hacky way to reconstruct the serialized error.
Expand Down
12 changes: 9 additions & 3 deletions lib/cast/cast_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,15 @@ shaka.cast.CastUtils.serialize = function(thing) {

if (typeof value == 'number') {
// NaN and infinity cannot be represented directly in JSON.
if (isNaN(value)) return 'NaN';
if (isFinite(value)) return value;
if (value < 0) return '-Infinity';
if (isNaN(value)) {
return 'NaN';
}
if (isFinite(value)) {
return value;
}
if (value < 0) {
return '-Infinity';
}
return 'Infinity';
}

Expand Down
20 changes: 15 additions & 5 deletions lib/dash/dash_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ shaka.dash.DashParser.prototype.stop = function() {
*/
shaka.dash.DashParser.prototype.update = function() {
this.requestManifest_().catch((error) => {
if (!this.playerInterface_ || !error) return;
if (!this.playerInterface_ || !error) {
return;
}
goog.asserts.assert(error instanceof shaka.util.Error, 'Bad error type');
this.playerInterface_.onError(error);
});
Expand Down Expand Up @@ -593,7 +595,9 @@ shaka.dash.DashParser.prototype.processManifest_ =

// Use @maxSegmentDuration to override smaller, derived values.
presentationTimeline.notifyMaxSegmentDuration(maxSegmentDuration || 1);
if (goog.DEBUG) presentationTimeline.assertIsValid();
if (goog.DEBUG) {
presentationTimeline.assertIsValid();
}

// These steps are not done on manifest update.
if (!this.manifest_) {
Expand Down Expand Up @@ -1462,10 +1466,14 @@ shaka.dash.DashParser.prototype.parseAudioChannels_ =
const elem = audioChannelConfigs[i];

const scheme = elem.getAttribute('schemeIdUri');
if (!scheme) continue;
if (!scheme) {
continue;
}

const value = elem.getAttribute('value');
if (!value) continue;
if (!value) {
continue;
}

switch (scheme) {
case 'urn:mpeg:dash:outputChannelPositionList:2012':
Expand Down Expand Up @@ -1497,7 +1505,9 @@ shaka.dash.DashParser.prototype.parseAudioChannels_ =
// Count the 1-bits in hexValue.
let numBits = 0;
while (hexValue) {
if (hexValue & 1) ++numBits;
if (hexValue & 1) {
++numBits;
}
hexValue >>= 1;
}
return numBits;
Expand Down
2 changes: 1 addition & 1 deletion lib/dash/segment_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ shaka.dash.SegmentBase.createInitSegment = function(context, callback) {
endByte = range.end;
}

const getUris = function() { return resolvedUris; };
const getUris = () => resolvedUris;
return new shaka.media.InitSegmentReference(getUris, startByte, endByte);
};

Expand Down
2 changes: 1 addition & 1 deletion lib/dash/segment_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ shaka.dash.SegmentList.createSegmentReferences_ = function(
endTime = startTime + periodDuration;
}

const getUris = (function(uris) { return uris; }.bind(null, mediaUri));
const getUris = () => mediaUri;
references.push(
new shaka.media.SegmentReference(
i + startNumber, startTime, endTime, getUris, segment.start,
Expand Down
4 changes: 3 additions & 1 deletion lib/dash/segment_template.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,9 @@ shaka.dash.SegmentTemplate.createFromDuration_ = function(context, info) {
// Cap the segment end at the period end, to avoid period transition issues
// in StreamingEngine.
let segmentEnd = segmentStart + segmentDuration;
if (periodDuration) segmentEnd = Math.min(segmentEnd, periodDuration);
if (periodDuration) {
segmentEnd = Math.min(segmentEnd, periodDuration);
}

// Do not construct segments references that should not exist.
if (segmentEnd < 0) {
Expand Down
24 changes: 18 additions & 6 deletions lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,9 @@ shaka.hls.HlsParser.prototype.createStreamInfoFromMediaTag_ =
// Shaka recognizes the content types 'audio', 'video' and 'text'.
// The HLS 'subtitles' type needs to be mapped to 'text'.
const ContentType = shaka.util.ManifestParserUtils.ContentType;
if (type == 'subtitles') type = ContentType.TEXT;
if (type == 'subtitles') {
type = ContentType.TEXT;
}

const LanguageUtils = shaka.util.LanguageUtils;
const language = LanguageUtils.normalize(/** @type {string} */(
Expand All @@ -1012,7 +1014,9 @@ shaka.hls.HlsParser.prototype.createStreamInfoFromMediaTag_ =
const streamInfo = await this.createStreamInfo_(
verbatimMediaPlaylistUri, allCodecs, type, language, primary, name,
channelsCount, /* closedCaptions */ null);
if (streamInfo == null) return null;
if (streamInfo == null) {
return null;
}
// TODO: This check is necessary because of the possibility of multiple
// calls to createStreamInfoFromMediaTag_ before either has resolved.
if (this.uriToStreamInfosMap_.has(verbatimMediaPlaylistUri)) {
Expand All @@ -1037,7 +1041,9 @@ shaka.hls.HlsParser.prototype.createStreamInfoFromMediaTag_ =
* @private
*/
shaka.hls.HlsParser.prototype.getChannelCount_ = function(channels) {
if (!channels) return null;
if (!channels) {
return null;
}
const channelcountstring = channels.split('/')[0];
const count = parseInt(channelcountstring, 10);
return count;
Expand Down Expand Up @@ -1083,7 +1089,9 @@ shaka.hls.HlsParser.prototype.createStreamInfoFromVariantTag_ =
const streamInfo = await this.createStreamInfo_(verbatimMediaPlaylistUri,
allCodecs, type, /* language */ 'und', /* primary */ false,
/* name */ null, /* channelcount */ null, closedCaptions);
if (streamInfo == null) return null;
if (streamInfo == null) {
return null;
}
// TODO: This check is necessary because of the possibility of multiple
// calls to createStreamInfoFromVariantTag_ before either has resolved.
if (this.uriToStreamInfosMap_.has(verbatimMediaPlaylistUri)) {
Expand Down Expand Up @@ -1806,11 +1814,15 @@ shaka.hls.HlsParser.prototype.getStartTimeFromTsSegment_ = function(data) {
packetStart = reader.getPosition();

syncByte = reader.readUint8();
if (syncByte != 0x47) fail();
if (syncByte != 0x47) {
fail();
}

const flagsAndPacketId = reader.readUint16();
const hasPesPacket = flagsAndPacketId & 0x4000;
if (!hasPesPacket) fail();
if (!hasPesPacket) {
fail();
}

const flags = reader.readUint8();
const adaptationFieldControl = (flags & 0x30) >> 4;
Expand Down
4 changes: 3 additions & 1 deletion lib/hls/hls_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ shaka.hls.Utils.filterTagsByName = function(tags, name) {
*/
shaka.hls.Utils.getFirstTagWithName = function(tags, name) {
const tagsWithName = shaka.hls.Utils.filterTagsByName(tags, name);
if (!tagsWithName.length) return null;
if (!tagsWithName.length) {
return null;
}

return tagsWithName[0];
};
Expand Down
12 changes: 9 additions & 3 deletions lib/media/adaptation_set.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ shaka.media.AdaptationSet = class {
codecsB.sort();

for (let i = 0; i < codecsA.length; i++) {
if (codecsA[i] != codecsB[i]) { return false; }
if (codecsA[i] != codecsB[i]) {
return false;
}
}

return true;
Expand All @@ -247,12 +249,16 @@ shaka.media.AdaptationSet = class {

// Make sure that we have the same number roles in each list. Make sure to
// do it after correcting for 'main'.
if (aSet.size != bSet.size) { return false; }
if (aSet.size != bSet.size) {
return false;
}

// Because we know the two sets are the same size, if any item is missing
// if means that they are not the same.
for (const x of aSet) {
if (!bSet.has(x)) { return false; }
if (!bSet.has(x)) {
return false;
}
}

return true;
Expand Down
Loading

0 comments on commit 0dd6407

Please sign in to comment.