Fix linting errors

This commit is contained in:
Jerko Steiner 2019-11-14 00:27:22 -03:00
parent 0b068dbe1d
commit 7e3956068b
8 changed files with 18 additions and 18 deletions

View File

@ -1,16 +1,16 @@
module.exports = {
roots: [
'<rootDir>/src'
'<rootDir>/src',
],
transform: {
'^.+\\.tsx?$': 'ts-jest'
'^.+\\.tsx?$': 'ts-jest',
},
testRegex: '(/__tests__/.*|\\.(test|spec))\\.tsx?$',
moduleFileExtensions: [
'ts',
'tsx',
'js',
'jsx'
'jsx',
],
setupFiles: ['<rootDir>/jest.setup.js']
setupFiles: ['<rootDir>/jest.setup.js'],
}

View File

@ -22,8 +22,8 @@
"js:uglify": "minify build/index.prod.js -o build/index.js",
"css": "node-sass ./src/scss/style.scss -o ./build/",
"css:watch": "npm run css && node-sass --watch ./src/scss/style.scss -o ./build/",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"lint": "eslint --ext ts,tsx .",
"lint:fix": "eslint --ext ts,tsx --fix .",
"ci": "npm run lint && npm run test:coverage && npm run build",
"ts:watch": "tsc -p . --watch --preserveWatchOutput",
"ts": "tsc -p .",

View File

@ -15,11 +15,13 @@ export class MediaStream {
}
}
export function getUserMedia () {
return !(getUserMedia as any).shouldFail
return !getUserMedia.shouldFail
? Promise.resolve(getUserMedia.stream)
: Promise.reject(new Error('test'))
}
getUserMedia.fail = (shouldFail: boolean) => (getUserMedia as any).shouldFail = shouldFail
getUserMedia.shouldFail = false
getUserMedia.fail = (shouldFail: boolean) =>
getUserMedia.shouldFail = shouldFail
getUserMedia.stream = new MediaStream()
export const navigator = window.navigator

View File

@ -1,4 +1,4 @@
import { Action, Dispatch } from 'redux'
import { Action } from 'redux'
export type PendingAction<T extends string, P> = Action<T> & Promise<P> & {
status: 'pending'

View File

@ -1,9 +1,8 @@
import Input from './Input'
import PropTypes from 'prop-types'
import React from 'react'
import classnames from 'classnames'
import React from 'react'
import { Message as MessageType } from '../actions/ChatActions'
import { TextMessage } from '../actions/PeerActions'
import Input from './Input'
export interface MessageProps {
message: MessageType

View File

@ -37,14 +37,11 @@ export default class Video extends React.PureComponent<VideoProps> {
const video = this.videoRef.current!
const mediaStream = stream && stream.stream || null
const url = stream && stream.url
console.log('stream', stream)
if ('srcObject' in video as unknown) {
if (video.srcObject !== mediaStream) {
console.log('setting srcObject')
video.srcObject = mediaStream
}
} else if (video.src !== url) {
console.log('setting src')
video.src = url || ''
}
videos[socket.id] = video

View File

@ -34,7 +34,7 @@ describe('reducers/alerts', () => {
store.dispatch(StreamActions.addStream({ userId, stream }))
expect(store.getState().streams).toEqual({
[userId]: {
mediaStream: stream,
stream: stream,
url: jasmine.any(String),
},
})
@ -45,7 +45,7 @@ describe('reducers/alerts', () => {
store.dispatch(StreamActions.addStream({ userId, stream }))
expect(store.getState().streams).toEqual({
[userId]: {
mediaStream: stream,
stream: stream,
url: null,
},
})

View File

@ -9,7 +9,9 @@ export async function getUserMedia (constraints: MediaStreamConstraints) {
return new Promise<MediaStream>((resolve, reject) => {
const getMedia = navigator.getUserMedia ||
(navigator as any).webkitGetUserMedia
(navigator as unknown as {
webkitGetUserMedia: typeof navigator.getUserMedia
}).webkitGetUserMedia
if (!getMedia) reject(new Error('Browser unsupported'))
getMedia.call(navigator, constraints, resolve, reject)
})