Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit 536eb6e

Browse files
authored
Fix ESLint errors and enforce ESLint rules by default (#332)
* Turn indentation rule on as a warning. * Fix some lint errors. * Enforce ESLint rules by default. * Address comments.
1 parent 8c7d3c7 commit 536eb6e

File tree

12 files changed

+103
-63
lines changed

12 files changed

+103
-63
lines changed

scripts/Gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,5 +263,5 @@ window.L = L;\n\
263263
grunt.registerTask('pack', ['browserify:dist', 'concat:rest', 'uglify:dist', 'copy:dist', 'string-replace', 'compress:dist', 'jsdoc:dist']);
264264
grunt.registerTask('dev', ['browserify:dev', 'connect:server']);
265265
grunt.registerTask('debug', ['browserify:dev']);
266-
grunt.registerTask('default', ['pack']);
266+
grunt.registerTask('default', ['check', 'pack']);
267267
};

src/.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"ignorePattern": "The above copyright notice and this permission notice shall be included in all",
1414
// Some lines for JSDoc is longer than 80.
1515
"ignoreComments": true
16-
}]
16+
}],
17+
"indent": ["warn"]
1718
}
1819
}

src/sdk/base/codec.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export class AudioCodecParameters {
3434
* @member {string} name
3535
* @memberof Owt.Base.AudioCodecParameters
3636
* @instance
37-
* @desc Name of a codec. Please use a value in Owt.Base.AudioCodec. However, some functions do not support all the values in Owt.Base.AudioCodec.
37+
* @desc Name of a codec. Please a value in Owt.Base.AudioCodec. However,
38+
* some functions do not support all the values in Owt.Base.AudioCodec.
3839
*/
3940
this.name = name;
4041
/**
@@ -105,7 +106,8 @@ export class VideoCodecParameters {
105106
* @member {string} name
106107
* @memberof Owt.Base.VideoCodecParameters
107108
* @instance
108-
* @desc Name of a codec. Please use a value in Owt.Base.VideoCodec. However, some functions do not support all the values in Owt.Base.AudioCodec.
109+
* @desc Name of a codec.Please a value in Owt.Base.AudioCodec.However,
110+
some functions do not support all the values in Owt.Base.AudioCodec.
109111
*/
110112
this.name = name;
111113
/**

src/sdk/base/event.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ export const EventDispatcher = function() {
4242

4343
/**
4444
* @function addEventListener
45-
* @desc This function registers a callback function as a handler for the corresponding event. It's shortened form is on(eventType, listener). See the event description in the following table.
45+
* @desc This function registers a callback function as a handler for the
46+
* corresponding event. It's shortened form is on(eventType, listener). See
47+
* the event description in the following table.
4648
* @instance
4749
* @memberof Owt.Base.EventDispatcher
4850
* @param {string} eventType Event string.
@@ -136,7 +138,8 @@ export class MessageEvent extends OwtEvent {
136138
* @member {string} to
137139
* @instance
138140
* @memberof Owt.Base.MessageEvent
139-
* @desc Values could be "all", "me" in conference mode, or undefined in P2P mode..
141+
* @desc Values could be "all", "me" in conference mode, or undefined in
142+
* P2P mode.
140143
*/
141144
this.to = init.to;
142145
}

src/sdk/base/mediaformat.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
'use strict';
66
/**
77
* @class AudioSourceInfo
8-
* @classDesc Source info about an audio track. Values: 'mic', 'screen-cast', 'file', 'mixed'.
8+
* @classDesc Source info about an audio track. Values: 'mic', 'screen-cast',
9+
* 'file', 'mixed'.
910
* @memberOf Owt.Base
1011
* @readonly
1112
* @enum {string}
@@ -19,7 +20,8 @@ export const AudioSourceInfo = {
1920

2021
/**
2122
* @class VideoSourceInfo
22-
* @classDesc Source info about a video track. Values: 'camera', 'screen-cast', 'file', 'mixed'.
23+
* @classDesc Source info about a video track. Values: 'camera', 'screen-cast',
24+
* 'file', 'mixed'.
2325
* @memberOf Owt.Base
2426
* @readonly
2527
* @enum {string}
@@ -33,7 +35,8 @@ export const VideoSourceInfo = {
3335

3436
/**
3537
* @class TrackKind
36-
* @classDesc Kind of a track. Values: 'audio' for audio track, 'video' for video track, 'av' for both audio and video tracks.
38+
* @classDesc Kind of a track. Values: 'audio' for audio track, 'video' for
39+
* video track, 'av' for both audio and video tracks.
3740
* @memberOf Owt.Base
3841
* @readonly
3942
* @enum {string}

src/sdk/base/mediastream-factory.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,21 +115,26 @@ export class StreamConstraints {
115115
// eslint-disable-next-line require-jsdoc
116116
function isVideoConstrainsForScreenCast(constraints) {
117117
return (typeof constraints.video === 'object' && constraints.video.source ===
118-
MediaFormatModule.VideoSourceInfo.SCREENCAST);
118+
MediaFormatModule.VideoSourceInfo.SCREENCAST);
119119
}
120120

121121
/**
122122
* @class MediaStreamFactory
123-
* @classDesc A factory to create MediaStream. You can also create MediaStream by yourself.
123+
* @classDesc A factory to create MediaStream. You can also create MediaStream
124+
* by yourself.
124125
* @memberof Owt.Base
125126
*/
126127
export class MediaStreamFactory {
127128
/**
128129
* @function createMediaStream
129130
* @static
130-
* @desc Create a MediaStream with given constraints. If you want to create a MediaStream for screen cast, please make sure both audio and video's source are "screen-cast".
131+
* @desc Create a MediaStream with given constraints. If you want to create a
132+
* MediaStream for screen cast, please make sure both audio and video's source
133+
* are "screen-cast".
131134
* @memberof Owt.Base.MediaStreamFactory
132-
* @return {Promise<MediaStream, Error>} Return a promise that is resolved when stream is successfully created, or rejected if one of the following error happened:
135+
* @return {Promise<MediaStream, Error>} Return a promise that is resolved
136+
* when stream is successfully created, or rejected if one of the following
137+
* error happened:
133138
* - One or more parameters cannot be satisfied.
134139
* - Specified device is busy.
135140
* - Cannot obtain necessary permission or operation is canceled by user.

src/sdk/base/publication.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ export class Publication extends EventDispatcher {
137137
/**
138138
* @function stop
139139
* @instance
140-
* @desc Stop certain publication. Once a subscription is stopped, it cannot be recovered.
140+
* @desc Stop certain publication. Once a subscription is stopped, it cannot
141+
* be recovered.
141142
* @memberof Owt.Base.Publication
142143
* @returns {undefined}
143144
*/
@@ -174,7 +175,8 @@ export class Publication extends EventDispatcher {
174175
/**
175176
* @class PublishOptions
176177
* @memberOf Owt.Base
177-
* @classDesc PublishOptions defines options for publishing a Owt.Base.LocalStream.
178+
* @classDesc PublishOptions defines options for publishing a
179+
* Owt.Base.LocalStream.
178180
*/
179181
export class PublishOptions {
180182
// eslint-disable-next-line require-jsdoc

src/sdk/base/stream.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
//
33
// SPDX-License-Identifier: Apache-2.0
44

5+
/* global MediaStream */
6+
57
'use strict';
6-
import {OwtEvent} from './event.js';
78
import * as Utils from './utils.js';
8-
import {EventDispatcher} from './event.js';
9+
import {EventDispatcher, OwtEvent} from './event.js';
910

1011
// eslint-disable-next-line require-jsdoc
1112
function isAllowedValue(obj, allowedValues) {
@@ -18,9 +19,12 @@ function isAllowedValue(obj, allowedValues) {
1819
* @memberOf Owt.Base
1920
* @classDesc Information of a stream's source.
2021
* @constructor
21-
* @description Audio source info or video source info could be undefined if a stream does not have audio/video track.
22-
* @param {?string} audioSourceInfo Audio source info. Accepted values are: "mic", "screen-cast", "file", "mixed" or undefined.
23-
* @param {?string} videoSourceInfo Video source info. Accepted values are: "camera", "screen-cast", "file", "mixed" or undefined.
22+
* @description Audio source info or video source info could be undefined if
23+
* a stream does not have audio/video track.
24+
* @param {?string} audioSourceInfo Audio source info. Accepted values are:
25+
* "mic", "screen-cast", "file", "mixed" or undefined.
26+
* @param {?string} videoSourceInfo Video source info. Accepted values are:
27+
* "camera", "screen-cast", "file", "mixed" or undefined.
2428
*/
2529
export class StreamSourceInfo {
2630
// eslint-disable-next-line require-jsdoc
@@ -98,7 +102,8 @@ export class Stream extends EventDispatcher {
98102
* @extends Owt.Base.Stream
99103
* @constructor
100104
* @param {MediaStream} stream Underlying MediaStream.
101-
* @param {Owt.Base.StreamSourceInfo} sourceInfo Information about stream's source.
105+
* @param {Owt.Base.StreamSourceInfo} sourceInfo Information about stream's
106+
* source.
102107
* @param {object} attributes Custom attributes of the stream.
103108
*/
104109
export class LocalStream extends Stream {
@@ -163,14 +168,17 @@ export class RemoteStream extends Stream {
163168
* @member {Owt.Base.PublicationSettings} settings
164169
* @instance
165170
* @memberof Owt.Base.RemoteStream
166-
* @desc Original settings for publishing this stream. This property is only valid in conference mode.
171+
* @desc Original settings for publishing this stream. This property is only
172+
* valid in conference mode.
167173
*/
168174
this.settings = undefined;
169175
/**
170176
* @member {Owt.Conference.SubscriptionCapabilities} extraCapabilities
171177
* @instance
172178
* @memberof Owt.Base.RemoteStream
173-
* @desc Extra capabilities remote endpoint provides for subscription. Extra capabilities don't include original settings. This property is only valid in conference mode.
179+
* @desc Extra capabilities remote endpoint provides for subscription. Extra
180+
* capabilities don't include original settings. This property is only valid
181+
* in conference mode.
174182
*/
175183
this.extraCapabilities = undefined;
176184
}

src/sdk/conference/channel.js

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// SPDX-License-Identifier: Apache-2.0
44

55
/* eslint-disable require-jsdoc */
6-
/* global Promise */
6+
/* global Promise, RTCPeerConnection */
77

88
'use strict';
99

@@ -24,7 +24,8 @@ import * as SdpUtils from '../base/sdputils.js';
2424

2525
/**
2626
* @class ConferencePeerConnectionChannel
27-
* @classDesc A channel for a connection between client and conference server. Currently, only one stream could be tranmitted in a channel.
27+
* @classDesc A channel for a connection between client and conference server.
28+
* Currently, only one stream could be tranmitted in a channel.
2829
* @hideconstructor
2930
* @private
3031
*/
@@ -53,7 +54,8 @@ export class ConferencePeerConnectionChannel extends EventDispatcher {
5354

5455
/**
5556
* @function onMessage
56-
* @desc Received a message from conference portal. Defined in client-server protocol.
57+
* @desc Received a message from conference portal. Defined in client-server
58+
* protocol.
5759
* @param {string} notification Notification type.
5860
* @param {object} message Message received.
5961
* @private
@@ -79,8 +81,10 @@ export class ConferencePeerConnectionChannel extends EventDispatcher {
7981

8082
publish(stream, options, videoCodecs) {
8183
if (options === undefined) {
82-
options = {audio: !!stream.mediaStream.getAudioTracks().length, video: !!stream
83-
.mediaStream.getVideoTracks().length};
84+
options = {
85+
audio: !!stream.mediaStream.getAudioTracks().length,
86+
video: !!stream.mediaStream.getVideoTracks().length,
87+
};
8488
}
8589
if (typeof options !== 'object') {
8690
return Promise.reject(new TypeError('Options should be an object.'));
@@ -90,7 +94,8 @@ export class ConferencePeerConnectionChannel extends EventDispatcher {
9094
(this._isOwtEncodingParameters(options.audio) &&
9195
this._isRtpEncodingParameters(options.video))) {
9296
return Promise.reject(new ConferenceError(
93-
'Mixing RTCRtpEncodingParameters and AudioEncodingParameters/VideoEncodingParameters is not allowed.'))
97+
'Mixing RTCRtpEncodingParameters and ' +
98+
'AudioEncodingParameters/VideoEncodingParameters is not allowed.'));
9499
}
95100
if (options.audio === undefined) {
96101
options.audio = !!stream.mediaStream.getAudioTracks().length;
@@ -203,13 +208,13 @@ export class ConferencePeerConnectionChannel extends EventDispatcher {
203208
if (mediaOptions.audio && stream.mediaStream.getAudioTracks().length >
204209
0) {
205210
const transceiverInit = {
206-
direction: 'sendonly'
211+
direction: 'sendonly',
207212
};
208213
if (this._isRtpEncodingParameters(options.audio)) {
209214
transceiverInit.sendEncodings = options.audio;
210215
}
211-
const transceiver = this._pc.addTransceiver(stream.mediaStream.getAudioTracks()[0],
212-
transceiverInit);
216+
const transceiver = this._pc.addTransceiver(
217+
stream.mediaStream.getAudioTracks()[0], transceiverInit);
213218

214219
if (Utils.isFirefox()) {
215220
// Firefox does not support encodings setting in addTransceiver.
@@ -221,32 +226,36 @@ export class ConferencePeerConnectionChannel extends EventDispatcher {
221226
if (mediaOptions.video && stream.mediaStream.getVideoTracks().length >
222227
0) {
223228
const transceiverInit = {
224-
direction: 'sendonly'
229+
direction: 'sendonly',
225230
};
226231
if (this._isRtpEncodingParameters(options.video)) {
227232
transceiverInit.sendEncodings = options.video;
228233
this._videoCodecs = videoCodecs;
229234
}
230-
const transceiver = this._pc.addTransceiver(stream.mediaStream.getVideoTracks()[0],
231-
transceiverInit);
235+
const transceiver = this._pc.addTransceiver(
236+
stream.mediaStream.getVideoTracks()[0], transceiverInit);
232237

233238
if (Utils.isFirefox()) {
234239
// Firefox does not support encodings setting in addTransceiver.
235240
const parameters = transceiver.sender.getParameters();
236241
parameters.encodings = transceiverInit.sendEncodings;
237242
setPromise = setPromise.then(
238-
() => transceiver.sender.setParameters(parameters));
243+
() => transceiver.sender.setParameters(parameters));
239244
}
240245
}
241246
return setPromise.then(() => offerOptions);
242247
} else {
243-
if (mediaOptions.audio && stream.mediaStream.getAudioTracks().length > 0) {
244-
for (const track of stream.mediaStream.getAudioTracks())
248+
if (mediaOptions.audio &&
249+
stream.mediaStream.getAudioTracks().length > 0) {
250+
for (const track of stream.mediaStream.getAudioTracks()) {
245251
this._pc.addTrack(track, stream.mediaStream);
252+
}
246253
}
247-
if (mediaOptions.video && stream.mediaStream.getVideoTracks().length > 0) {
248-
for (const track of stream.mediaStream.getVideoTracks())
254+
if (mediaOptions.video &&
255+
stream.mediaStream.getVideoTracks().length > 0) {
256+
for (const track of stream.mediaStream.getVideoTracks()) {
249257
this._pc.addTrack(track, stream.mediaStream);
258+
}
250259
}
251260
offerOptions.offerToReceiveAudio = false;
252261
offerOptions.offerToReceiveVideo = false;
@@ -351,7 +360,7 @@ export class ConferencePeerConnectionChannel extends EventDispatcher {
351360
framerate: options.video.frameRate,
352361
bitrate: options.video.bitrateMultiplier ? 'x'
353362
+ options.video.bitrateMultiplier.toString() : undefined,
354-
keyFrameInterval: options.video.keyFrameInterval
363+
keyFrameInterval: options.video.keyFrameInterval,
355364
};
356365
}
357366
if (options.video.rid) {

src/sdk/conference/mixedstream.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ export class RemoteMixedStream extends StreamModule.RemoteStream {
3333

3434
this.settings = StreamUtilsModule.convertToPublicationSettings(info.media);
3535

36-
this.extraCapabilities = StreamUtilsModule
37-
.convertToSubscriptionCapabilities(info.media);
36+
this.extraCapabilities =
37+
StreamUtilsModule.convertToSubscriptionCapabilities(info.media);
3838
}
3939
}
4040

0 commit comments

Comments
 (0)