Skip to content

Commit

Permalink
ESLint: Require curly braces in switch cases and update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
ibc committed Dec 15, 2023
1 parent af8bd1a commit be46159
Show file tree
Hide file tree
Showing 18 changed files with 489 additions and 176 deletions.
10 changes: 10 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ const eslintConfig =
'computed-property-spacing' : 2,
'constructor-super' : 2,
'curly' : [ 2, 'all' ],
// Unfortunatelly `curly` does not apply to blocks in `switch` cases so
// this is needed.
// NOTE: We disable this rule since it's producing false positives:
// https://github.com/versatica/mediasoup/pull/1268
// 'no-restricted-syntax' : [ 2,
// {
// 'selector' : 'SwitchCase:has(*.consequent[type!="BlockStatement"])',
// 'message' : 'Switch cases without blocks are disallowed'
// }
// ],
'func-call-spacing' : 2,
'generator-star-spacing' : 2,
'guard-for-in' : 2,
Expand Down
346 changes: 173 additions & 173 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@
"@types/jest": "^29.5.11",
"@types/sdp-transform": "^2.4.9",
"@types/ua-parser-js": "^0.7.39",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.13.2",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"eslint": "^8.55.0",
"eslint-plugin-jest": "^27.6.0",
"jest": "^29.7.0",
"open-cli": "^7.2.0",
"ts-jest": "^29.1.1",
"typescript": "^5.3.2"
"typescript": "^5.3.3"
}
}
35 changes: 35 additions & 0 deletions src/Device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,40 +332,75 @@ export class Device
switch (handlerName)
{
case 'Chrome111':
{
this._handlerFactory = Chrome111.createFactory();
break;
}

case 'Chrome74':
{
this._handlerFactory = Chrome74.createFactory();
break;
}

case 'Chrome70':
{
this._handlerFactory = Chrome70.createFactory();
break;
}

case 'Chrome67':
{
this._handlerFactory = Chrome67.createFactory();
break;
}

case 'Chrome55':
{
this._handlerFactory = Chrome55.createFactory();
break;
}

case 'Firefox60':
{
this._handlerFactory = Firefox60.createFactory();
break;
}

case 'Safari12':
{
this._handlerFactory = Safari12.createFactory();
break;
}

case 'Safari11':
{
this._handlerFactory = Safari11.createFactory();
break;
}

case 'Edge11':
{
this._handlerFactory = Edge11.createFactory();
break;
}

case 'ReactNativeUnifiedPlan':
{
this._handlerFactory = ReactNativeUnifiedPlan.createFactory();
break;
}

case 'ReactNative':
{
this._handlerFactory = ReactNative.createFactory();
break;
}

default:
{
throw new TypeError(`unknown handlerName "${handlerName}"`);
}
}
}

Expand Down
19 changes: 19 additions & 0 deletions src/handlers/Chrome111.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,21 +229,40 @@ export class Chrome111 extends HandlerInterface
switch (this._pc.iceConnectionState)
{
case 'checking':
{
this.emit('@connectionstatechange', 'connecting');

break;
}

case 'connected':
case 'completed':
{
this.emit('@connectionstatechange', 'connected');

break;
}

case 'failed':
{
this.emit('@connectionstatechange', 'failed');

break;
}

case 'disconnected':
{
this.emit('@connectionstatechange', 'disconnected');

break;
}

case 'closed':
{
this.emit('@connectionstatechange', 'closed');

break;
}
}
});
}
Expand Down
19 changes: 19 additions & 0 deletions src/handlers/Chrome55.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,21 +226,40 @@ export class Chrome55 extends HandlerInterface
switch (this._pc.iceConnectionState)
{
case 'checking':
{
this.emit('@connectionstatechange', 'connecting');

break;
}

case 'connected':
case 'completed':
{
this.emit('@connectionstatechange', 'connected');

break;
}

case 'failed':
{
this.emit('@connectionstatechange', 'failed');

break;
}

case 'disconnected':
{
this.emit('@connectionstatechange', 'disconnected');

break;
}

case 'closed':
{
this.emit('@connectionstatechange', 'closed');

break;
}
}
});
}
Expand Down
19 changes: 19 additions & 0 deletions src/handlers/Chrome67.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,21 +227,40 @@ export class Chrome67 extends HandlerInterface
switch (this._pc.iceConnectionState)
{
case 'checking':
{
this.emit('@connectionstatechange', 'connecting');

break;
}

case 'connected':
case 'completed':
{
this.emit('@connectionstatechange', 'connected');

break;
}

case 'failed':
{
this.emit('@connectionstatechange', 'failed');

break;
}

case 'disconnected':
{
this.emit('@connectionstatechange', 'disconnected');

break;
}

case 'closed':
{
this.emit('@connectionstatechange', 'closed');

break;
}
}
});
}
Expand Down
19 changes: 19 additions & 0 deletions src/handlers/Chrome70.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,21 +213,40 @@ export class Chrome70 extends HandlerInterface
switch (this._pc.iceConnectionState)
{
case 'checking':
{
this.emit('@connectionstatechange', 'connecting');

break;
}

case 'connected':
case 'completed':
{
this.emit('@connectionstatechange', 'connected');

break;
}

case 'failed':
{
this.emit('@connectionstatechange', 'failed');

break;
}

case 'disconnected':
{
this.emit('@connectionstatechange', 'disconnected');

break;
}

case 'closed':
{
this.emit('@connectionstatechange', 'closed');

break;
}
}
});
}
Expand Down
19 changes: 19 additions & 0 deletions src/handlers/Chrome74.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,21 +231,40 @@ export class Chrome74 extends HandlerInterface
switch (this._pc.iceConnectionState)
{
case 'checking':
{
this.emit('@connectionstatechange', 'connecting');

break;
}

case 'connected':
case 'completed':
{
this.emit('@connectionstatechange', 'connected');

break;
}

case 'failed':
{
this.emit('@connectionstatechange', 'failed');

break;
}

case 'disconnected':
{
this.emit('@connectionstatechange', 'disconnected');

break;
}

case 'closed':
{
this.emit('@connectionstatechange', 'closed');

break;
}
}
});
}
Expand Down
38 changes: 38 additions & 0 deletions src/handlers/Edge11.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,21 +557,40 @@ export class Edge11 extends HandlerInterface
switch (iceTransport.state)
{
case 'checking':
{
this.emit('@connectionstatechange', 'connecting');

break;
}

case 'connected':
case 'completed':
{
this.emit('@connectionstatechange', 'connected');

break;
}

case 'failed':
{
this.emit('@connectionstatechange', 'failed');

break;
}

case 'disconnected':
{
this.emit('@connectionstatechange', 'disconnected');

break;
}

case 'closed':
{
this.emit('@connectionstatechange', 'closed');

break;
}
}
});

Expand All @@ -581,21 +600,40 @@ export class Edge11 extends HandlerInterface
switch (iceTransport.state)
{
case 'checking':
{
this.emit('@connectionstatechange', 'connecting');

break;
}

case 'connected':
case 'completed':
{
this.emit('@connectionstatechange', 'connected');

break;
}

case 'failed':
{
this.emit('@connectionstatechange', 'failed');

break;
}

case 'disconnected':
{
this.emit('@connectionstatechange', 'disconnected');

break;
}

case 'closed':
{
this.emit('@connectionstatechange', 'closed');

break;
}
}
});

Expand Down
Loading

0 comments on commit be46159

Please sign in to comment.