Skip to content

Commit dc2de5f

Browse files
committed
chore(ts): replace tslint with eslint
1 parent 3863ab8 commit dc2de5f

File tree

10 files changed

+651
-148
lines changed

10 files changed

+651
-148
lines changed

.eslintrc.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"extends": [
3+
"plugin:@typescript-eslint/recommended",
4+
"prettier",
5+
"prettier/@typescript-eslint"
6+
],
7+
"parser": "@typescript-eslint/parser",
8+
"parserOptions": {
9+
"project": "./tsconfig.json"
10+
},
11+
"plugins": ["@typescript-eslint"],
12+
"rules": {
13+
"@typescript-eslint/explicit-function-return-type": "off",
14+
"@typescript-eslint/explicit-member-accessibility": "off",
15+
"@typescript-eslint/camelcase": "off",
16+
"@typescript-eslint/no-explicit-any": "off",
17+
"@typescript-eslint/array-type": ["error", "array-simple"]
18+
}
19+
}

lib/components/auth/www-authenticate.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ export interface Challenge {
66
}
77

88
export const parseWWWAuthenticate = (header: string): Challenge => {
9-
const [dummy, type, ...challenge] = header.split(' ')
9+
const [, type, ...challenge] = header.split(' ')
1010

11-
const pairs: [string, string][] = []
11+
const pairs: Array<[string, string]> = []
1212
const re = /\s*([^=]+)=\"([^\"]*)\",?/gm
1313
let match
1414
do {
1515
match = re.exec(challenge.join(' '))
1616
if (match !== null) {
17-
const [full, key, value] = match
17+
const [, key, value] = match
1818
pairs.push([key, value])
1919
}
2020
} while (match !== null)

lib/components/component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Duplex, PassThrough, Readable, Stream, Writable } from 'stream'
22
import StreamFactory from './helpers/stream-factory'
3-
import { Message, MessageHandler, GenericMessage } from './message'
3+
import { MessageHandler, GenericMessage } from './message'
44

55
export type Component = Source | Tube | Sink
66

lib/components/mp4muxer/helpers/isom.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ const createParameterSetArrayClass = function(sizeMask = 0x00) {
254254
}
255255
}
256256

257-
load: BufferMutation = (buffer, offset) => {
257+
load: BufferMutation = () => {
258258
/** noop */
259259
}
260260
}
@@ -267,7 +267,7 @@ interface BoxSpec {
267267
mandatory?: boolean
268268
quantity?: string
269269
box: 'Box' | 'FullBox' | 'None'
270-
body?: [string, any, any?][]
270+
body?: Array<[string, any, any?]>
271271
config?: any
272272
}
273273

lib/utils/config.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export interface IConfigObject {
1+
export interface ConfigOptions {
22
[key: string]: any
33
}
44

@@ -8,20 +8,20 @@ export interface IConfigObject {
88
* @param {Object} override The object with override values.
99
* @return {Object} The template object with override merged in.
1010
*/
11-
export const merge = <T extends IConfigObject>(template: T, override: T): T => {
11+
export const merge = <T extends ConfigOptions>(template: T, override: T): T => {
1212
let cleanOverride
1313
if (override !== undefined) {
1414
if (typeof override !== 'object') {
1515
throw new Error('merge expects override to be an object!')
1616
} else {
1717
cleanOverride = Object.keys(override).reduce(
18-
(acc, key) => {
18+
(acc: ConfigOptions, key) => {
1919
if (override[key] !== undefined) {
2020
acc[key] = override[key]
2121
}
2222
return acc
2323
},
24-
{} as IConfigObject,
24+
{},
2525
)
2626
}
2727
}

lib/utils/protocols/sdp.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import { Session } from 'inspector'
2+
import { MessageType, SdpMessage } from '../../components/message'
3+
import { NtpSeconds, seconds } from './ntp'
4+
15
/**
26
* The session description protocol (SDP).
37
*
@@ -211,7 +215,7 @@ export interface AACMedia extends AudioMedia {
211215

212216
export interface Sdp {
213217
readonly session: Session
214-
readonly media: ReadonlyArray<MediaDescription>
218+
readonly media: MediaDescription[]
215219
}
216220

217221
const extractLineVals = (buffer: Buffer, lineStart: string, start = 0) => {
@@ -426,10 +430,6 @@ export const parse = (buffer: Buffer): Sdp => {
426430
return struct as Sdp
427431
}
428432

429-
import { Session } from 'inspector'
430-
import { MessageType, SdpMessage } from '../../components/message'
431-
import { NtpSeconds, seconds } from './ntp'
432-
433433
export const messageFromBuffer = (buffer: Buffer): SdpMessage => {
434434
return {
435435
type: MessageType.SDP,

lib/utils/scheduler.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export interface IClock {
1+
export interface Clock {
22
readonly currentTime: number
33
readonly play: () => void
44
readonly pause: () => void
@@ -35,7 +35,7 @@ const DEFAULT_TOLERANCE = 10
3535
*/
3636

3737
export default class Scheduler<T extends { readonly ntpTimestamp?: number }> {
38-
private _clock: IClock
38+
private _clock: Clock
3939
private _handler: (msg: T) => void
4040
private _tolerance: number
4141
private _nextRun: number
@@ -52,7 +52,7 @@ export default class Scheduler<T extends { readonly ntpTimestamp?: number }> {
5252
* @memberof Scheduler
5353
*/
5454
constructor(
55-
clock: IClock,
55+
clock: Clock,
5656
handler: (msg: T) => void,
5757
tolerance = DEFAULT_TOLERANCE,
5858
) {
@@ -148,10 +148,14 @@ export default class Scheduler<T extends { readonly ntpTimestamp?: number }> {
148148
}
149149
// There is at least one message in the FIFO queue, either
150150
// display it, or re-schedule the method for later execution
151-
let timeToPresent: number = 0
151+
let timeToPresent = 0
152152
let currentMessage: T
153153
do {
154-
currentMessage = this._fifo.shift()!
154+
const msg = this._fifo.shift()
155+
if (msg === undefined) {
156+
throw new Error('internal error: message should never be undefined')
157+
}
158+
currentMessage = msg
155159
const ntpTimestamp = currentMessage.ntpTimestamp
156160
if (ntpTimestamp === undefined) {
157161
continue

package.json

+8-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"live": "examples/node/player.js"
1212
},
1313
"scripts": {
14-
"lint": "tslint --project tsconfig.json --format stylish",
14+
"lint": "eslint --ext '.ts,.js' lib/",
1515
"test": "jest --coverage",
1616
"verify": "yarn lint && yarn test",
1717
"build": "yarn build:esm && yarn build:cjs && yarn build:bundle",
@@ -47,18 +47,22 @@
4747
"@types/jest": "24.0.15",
4848
"@types/node": "12.0.10",
4949
"@types/ws": "6.0.1",
50+
"@typescript-eslint/eslint-plugin": "1.10.2",
51+
"@typescript-eslint/parser": "1.10.2",
5052
"babel-loader": "8.0.6",
5153
"core-js": "3.1.4",
5254
"cypress": "3.3.1",
55+
"eslint": "5.0.0",
56+
"eslint-config-prettier": "5.0.0",
57+
"eslint-plugin-import": "^2.17.3",
58+
"eslint-plugin-node": "^9.1.0",
59+
"eslint-plugin-promise": "^4.1.1",
5360
"http-server": "0.11.1",
5461
"jest": "24.8.0",
5562
"md5.js": "1.3.5",
5663
"mock-socket": "8.0.5",
5764
"prettier": "1.18.2",
5865
"ts-jest": "24.0.2",
59-
"tslint": "5.18.0",
60-
"tslint-config-prettier": "1.18.0",
61-
"tslint-config-standard": "8.0.1",
6266
"typescript": "3.5.2",
6367
"webpack": "4.35.0",
6468
"webpack-cli": "3.3.5"

tslint.json

-15
This file was deleted.

0 commit comments

Comments
 (0)