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

Commit 36da892

Browse files
authored
Merge pull request #172 from grgustaf/eslint-cleanup
Eslint cleanup
2 parents 6d6d0a4 + 8953ff5 commit 36da892

File tree

16 files changed

+146
-133
lines changed

16 files changed

+146
-133
lines changed

package-lock.json

Lines changed: 70 additions & 63 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020
"@babel/core": "^7.1.2",
2121
"@babel/preset-env": "^7.1.0",
2222
"babelify": "^10.0.0",
23+
"chai": "^4.2.0",
2324
"chai-as-promised": "^7.1.1",
2425
"eslint-config-google": "^0.11.0",
26+
"eslint-config-webrtc": "^1.0.0",
2527
"grunt": "^1.0.4",
2628
"grunt-browserify": "^5.2.0",
2729
"grunt-cli": "~1.3.1",

scripts/Gruntfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ window.L = L;\n\
258258
grunt.loadNpmTasks('grunt-contrib-connect');
259259
grunt.loadNpmTasks('grunt-jsdoc');
260260

261+
grunt.registerTask('check', ['eslint:src']);
261262
grunt.registerTask('prepare', ['browserify:sinon', 'browserify:chai_as_promised']);
262263
grunt.registerTask('pack', ['browserify:dist', 'concat:rest', 'uglify:dist', 'copy:dist', 'string-replace', 'compress:dist', 'jsdoc:dist']);
263264
grunt.registerTask('dev', ['browserify:dev', 'connect:server']);

src/sdk/base/logger.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
// This file is borrowed from lynckia/licode with some modifications.
2828

29-
/* global console,window */
29+
/* global window */
3030

3131
'use strict';
3232

src/sdk/base/mediastream-factory.js

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

5-
/* global console, window, Promise, chrome, navigator */
5+
/* global Promise, navigator */
66

77
'use strict';
88
import * as utils from './utils.js';
9-
import Logger from './logger.js';
109
import * as MediaFormatModule from './mediaformat.js';
1110

1211
/**
@@ -52,7 +51,7 @@ export class VideoTrackConstraints {
5251
// eslint-disable-next-line require-jsdoc
5352
constructor(source) {
5453
if (!Object.values(MediaFormatModule.VideoSourceInfo)
55-
.some((v) => v === source)) {
54+
.some((v) => v === source)) {
5655
throw new TypeError('Invalid source.');
5756
}
5857
/**
@@ -130,7 +129,7 @@ export class MediaStreamFactory {
130129
* @static
131130
* @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".
132131
* @memberof Owt.Base.MediaStreamFactory
133-
* @returns {Promise<MediaStream, Error>} Return a promise that is resolved when stream is successfully created, or rejected if one of the following error happened:
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:
134133
* - One or more parameters cannot be satisfied.
135134
* - Specified device is busy.
136135
* - Cannot obtain necessary permission or operation is canceled by user.
@@ -167,7 +166,7 @@ export class MediaStreamFactory {
167166
// Check and convert constraints.
168167
if (!constraints.audio && !constraints.video) {
169168
return Promise.reject(new TypeError(
170-
'At least one of audio and video must be requested.'));
169+
'At least one of audio and video must be requested.'));
171170
}
172171
const mediaConstraints = Object.create({});
173172
if (typeof constraints.audio === 'object' &&
@@ -181,7 +180,8 @@ export class MediaStreamFactory {
181180
};
182181
}
183182
} else {
184-
if (constraints.audio.source === MediaFormatModule.AudioSourceInfo.SCREENCAST) {
183+
if (constraints.audio.source ===
184+
MediaFormatModule.AudioSourceInfo.SCREENCAST) {
185185
mediaConstraints.audio = true;
186186
} else {
187187
mediaConstraints.audio = constraints.audio;
@@ -195,24 +195,21 @@ export class MediaStreamFactory {
195195
if (constraints.video.resolution &&
196196
constraints.video.resolution.width &&
197197
constraints.video.resolution.height) {
198-
if (constraints.video.source ===
198+
if (constraints.video.source ===
199199
MediaFormatModule.VideoSourceInfo.SCREENCAST) {
200-
mediaConstraints.video.width =
201-
constraints.video.resolution.width;
202-
mediaConstraints.video.height =
203-
constraints.video.resolution.height;
204-
} else {
205-
mediaConstraints.video.width = Object.create({});
206-
mediaConstraints.video.width.exact =
207-
constraints.video.resolution.width;
208-
mediaConstraints.video.height = Object.create({});
209-
mediaConstraints.video.height.exact =
210-
constraints.video.resolution.height;
211-
212-
}
200+
mediaConstraints.video.width = constraints.video.resolution.width;
201+
mediaConstraints.video.height = constraints.video.resolution.height;
202+
} else {
203+
mediaConstraints.video.width = Object.create({});
204+
mediaConstraints.video.width.exact =
205+
constraints.video.resolution.width;
206+
mediaConstraints.video.height = Object.create({});
207+
mediaConstraints.video.height.exact =
208+
constraints.video.resolution.height;
209+
}
213210
}
214211
if (typeof constraints.video.deviceId === 'string') {
215-
mediaConstraints.video.deviceId = { exact: constraints.video.deviceId };
212+
mediaConstraints.video.deviceId = {exact: constraints.video.deviceId};
216213
}
217214
if (utils.isFirefox() &&
218215
constraints.video.source ===

src/sdk/base/publication.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
'use strict';
66

77
import * as Utils from './utils.js';
8-
import * as MediaFormat from './mediaformat.js';
98
import {EventDispatcher} from '../base/event.js';
109

1110
/**

src/sdk/base/stream.js

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

55
'use strict';
6-
import Logger from './logger.js'
7-
import {OwtEvent} from './event.js'
8-
import * as Utils from './utils.js'
9-
import { EventDispatcher} from './event.js';
6+
import {OwtEvent} from './event.js';
7+
import * as Utils from './utils.js';
8+
import {EventDispatcher} from './event.js';
109

1110
// eslint-disable-next-line require-jsdoc
1211
function isAllowedValue(obj, allowedValues) {

src/sdk/base/utils.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ export function sysInfo() {
4343
};
4444
// Runtime info.
4545
const userAgent = navigator.userAgent;
46-
const firefoxRegex = /Firefox\/([0-9\.]+)/;
47-
const chromeRegex = /Chrome\/([0-9\.]+)/;
48-
const edgeRegex = /Edge\/([0-9\.]+)/;
49-
const safariVersionRegex = /Version\/([0-9\.]+) Safari/;
46+
const firefoxRegex = /Firefox\/([0-9.]+)/;
47+
const chromeRegex = /Chrome\/([0-9.]+)/;
48+
const edgeRegex = /Edge\/([0-9.]+)/;
49+
const safariVersionRegex = /Version\/([0-9.]+) Safari/;
5050
let result = chromeRegex.exec(userAgent);
5151
if (result) {
5252
info.runtime = {
@@ -76,11 +76,11 @@ export function sysInfo() {
7676
};
7777
}
7878
// OS info.
79-
const windowsRegex = /Windows NT ([0-9\.]+)/;
80-
const macRegex = /Intel Mac OS X ([0-9_\.]+)/;
81-
const iPhoneRegex = /iPhone OS ([0-9_\.]+)/;
79+
const windowsRegex = /Windows NT ([0-9.]+)/;
80+
const macRegex = /Intel Mac OS X ([0-9_.]+)/;
81+
const iPhoneRegex = /iPhone OS ([0-9_.]+)/;
8282
const linuxRegex = /X11; Linux/;
83-
const androidRegex = /Android( ([0-9\.]+))?/;
83+
const androidRegex = /Android( ([0-9.]+))?/;
8484
const chromiumOsRegex = /CrOS/;
8585
if (result = windowsRegex.exec(userAgent)) {
8686
info.os = {

src/sdk/conference/channel.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import {
1313
MessageEvent,
1414
OwtEvent,
1515
ErrorEvent,
16-
MuteEvent
16+
MuteEvent,
1717
} from '../base/event.js';
18-
import { TrackKind } from '../base/mediaformat.js'
19-
import { Publication } from '../base/publication.js';
20-
import { Subscription } from './subscription.js'
21-
import { ConferenceError } from './error.js'
18+
import {TrackKind} from '../base/mediaformat.js';
19+
import {Publication} from '../base/publication.js';
20+
import {Subscription} from './subscription.js';
21+
import {ConferenceError} from './error.js';
2222
import * as Utils from '../base/utils.js';
2323
import * as SdpUtils from '../base/sdputils.js';
2424

@@ -529,7 +529,7 @@ export class ConferencePeerConnectionChannel extends EventDispatcher {
529529

530530
_rejectPromise(error) {
531531
if (!error) {
532-
const error = new ConferenceError('Connection failed or closed.');
532+
error = new ConferenceError('Connection failed or closed.');
533533
}
534534
// Rejecting corresponding promise if publishing and subscribing is ongoing.
535535
if (this._publishPromise) {
@@ -666,7 +666,7 @@ export class ConferencePeerConnectionChannel extends EventDispatcher {
666666
return this._handleError(errorMessage);
667667
}
668668

669-
_handleError(errorMessage){
669+
_handleError(errorMessage) {
670670
const error = new ConferenceError(errorMessage);
671671
const p = this._publishPromise || this._subscribePromise;
672672
if (p) {

src/sdk/conference/client.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ export const ConferenceClient = function(config, signalingImpl) {
331331
* @instance
332332
* @desc Join a conference.
333333
* @memberof Owt.Conference.ConferenceClient
334-
* @returns {Promise<ConferenceInfo, Error>} Return a promise resolved with current conference's information if successfully join the conference. Or return a promise rejected with a newly created Owt.Error if failed to join the conference.
334+
* @return {Promise<ConferenceInfo, Error>} Return a promise resolved with current conference's information if successfully join the conference. Or return a promise rejected with a newly created Owt.Error if failed to join the conference.
335335
* @param {string} tokenString Token is issued by conference server(nuve).
336336
*/
337337
this.join = function(tokenString) {
@@ -395,7 +395,7 @@ export const ConferenceClient = function(config, signalingImpl) {
395395
* @param {Owt.Base.LocalStream} stream The stream to be published.
396396
* @param {Owt.Base.PublishOptions} options Options for publication.
397397
* @param {string[]} videoCodecs Video codec names for publishing. Valid values are 'VP8', 'VP9' and 'H264'. This parameter only valid when options.video is RTCRtpEncodingParameters. Publishing with RTCRtpEncodingParameters is an experimental feature. This parameter is subject to change.
398-
* @returns {Promise<Publication, Error>} Returned promise will be resolved with a newly created Publication once specific stream is successfully published, or rejected with a newly created Error if stream is invalid or options cannot be satisfied. Successfully published means PeerConnection is established and server is able to process media data.
398+
* @return {Promise<Publication, Error>} Returned promise will be resolved with a newly created Publication once specific stream is successfully published, or rejected with a newly created Error if stream is invalid or options cannot be satisfied. Successfully published means PeerConnection is established and server is able to process media data.
399399
*/
400400
this.publish = function(stream, options, videoCodecs) {
401401
if (!(stream instanceof StreamModule.LocalStream)) {
@@ -416,7 +416,7 @@ export const ConferenceClient = function(config, signalingImpl) {
416416
* @desc Subscribe a RemoteStream from conference server.
417417
* @param {Owt.Base.RemoteStream} stream The stream to be subscribed.
418418
* @param {Owt.Conference.SubscribeOptions} options Options for subscription.
419-
* @returns {Promise<Subscription, Error>} Returned promise will be resolved with a newly created Subscription once specific stream is successfully subscribed, or rejected with a newly created Error if stream is invalid or options cannot be satisfied. Successfully subscribed means PeerConnection is established and server was started to send media data.
419+
* @return {Promise<Subscription, Error>} Returned promise will be resolved with a newly created Subscription once specific stream is successfully subscribed, or rejected with a newly created Error if stream is invalid or options cannot be satisfied. Successfully subscribed means PeerConnection is established and server was started to send media data.
420420
*/
421421
this.subscribe = function(stream, options) {
422422
if (!(stream instanceof StreamModule.RemoteStream)) {

0 commit comments

Comments
 (0)