From 7e3956068b611ea7c322c8689f32f6a2745d517e Mon Sep 17 00:00:00 2001 From: Jerko Steiner Date: Thu, 14 Nov 2019 00:27:22 -0300 Subject: [PATCH] Fix linting errors --- jest.config.js | 8 ++++---- package.json | 4 ++-- src/client/__mocks__/window.ts | 6 ++++-- src/client/async/action.ts | 2 +- src/client/components/Chat.tsx | 5 ++--- src/client/components/Video.tsx | 3 --- src/client/reducers/streams.test.ts | 4 ++-- src/client/window.ts | 4 +++- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/jest.config.js b/jest.config.js index 737dab0..4c0cf86 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,16 +1,16 @@ module.exports = { roots: [ - '/src' + '/src', ], transform: { - '^.+\\.tsx?$': 'ts-jest' + '^.+\\.tsx?$': 'ts-jest', }, testRegex: '(/__tests__/.*|\\.(test|spec))\\.tsx?$', moduleFileExtensions: [ 'ts', 'tsx', 'js', - 'jsx' + 'jsx', ], - setupFiles: ['/jest.setup.js'] + setupFiles: ['/jest.setup.js'], } diff --git a/package.json b/package.json index a43391b..5c5ab10 100644 --- a/package.json +++ b/package.json @@ -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 .", diff --git a/src/client/__mocks__/window.ts b/src/client/__mocks__/window.ts index 6904fac..d303193 100644 --- a/src/client/__mocks__/window.ts +++ b/src/client/__mocks__/window.ts @@ -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 diff --git a/src/client/async/action.ts b/src/client/async/action.ts index e243757..8f3ffbc 100644 --- a/src/client/async/action.ts +++ b/src/client/async/action.ts @@ -1,4 +1,4 @@ -import { Action, Dispatch } from 'redux' +import { Action } from 'redux' export type PendingAction = Action & Promise

& { status: 'pending' diff --git a/src/client/components/Chat.tsx b/src/client/components/Chat.tsx index a7e4f38..ab368d8 100644 --- a/src/client/components/Chat.tsx +++ b/src/client/components/Chat.tsx @@ -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 diff --git a/src/client/components/Video.tsx b/src/client/components/Video.tsx index 992e48b..5ae2d2b 100644 --- a/src/client/components/Video.tsx +++ b/src/client/components/Video.tsx @@ -37,14 +37,11 @@ export default class Video extends React.PureComponent { 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 diff --git a/src/client/reducers/streams.test.ts b/src/client/reducers/streams.test.ts index c6e1368..3f5e4e3 100644 --- a/src/client/reducers/streams.test.ts +++ b/src/client/reducers/streams.test.ts @@ -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, }, }) diff --git a/src/client/window.ts b/src/client/window.ts index 5f74af3..97a4245 100644 --- a/src/client/window.ts +++ b/src/client/window.ts @@ -9,7 +9,9 @@ export async function getUserMedia (constraints: MediaStreamConstraints) { return new Promise((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) })