From 7231c458fb0af80370f308d3d77aab71c226aac6 Mon Sep 17 00:00:00 2001 From: Pete Cook Date: Wed, 10 Feb 2016 16:29:19 +0000 Subject: [PATCH] Update standard code style Can't say I'm a huge fan, but consistency is key --- package.json | 2 +- src/ReactPlayer.js | 8 +++---- src/demo/App.js | 46 +++++++++++++++++++-------------------- src/demo/Duration.js | 2 +- src/players/Base.js | 2 +- src/players/SoundCloud.js | 12 +++++----- src/players/Vimeo.js | 2 +- src/players/YouTube.js | 6 ++--- test/karma/ReactPlayer.js | 36 +++++++++++++++--------------- 9 files changed, 58 insertions(+), 58 deletions(-) diff --git a/package.json b/package.json index 9d852554..51a5d758 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "rimraf": "^2.4.4", "sass-loader": "^3.1.2", "snazzy": "^2.0.1", - "standard": "^5.4.1", + "standard": "^6.0.4", "style-loader": "^0.13.0", "webpack": "^1.12.9", "webpack-dev-middleware": "^1.4.0", diff --git a/src/ReactPlayer.js b/src/ReactPlayer.js index 6bed5a38..0d0e5f85 100644 --- a/src/ReactPlayer.js +++ b/src/ReactPlayer.js @@ -10,7 +10,7 @@ export default class ReactPlayer extends Component { static propTypes = propTypes; static defaultProps = defaultProps; static canPlay (url) { - return players.some(player => player.canPlay(url)) + return players.some((player) => player.canPlay(url)) } componentDidMount () { this.progress() @@ -25,7 +25,7 @@ export default class ReactPlayer extends Component { this.props.volume !== nextProps.volume ) } - seekTo = fraction => { + seekTo = (fraction) => { const player = this.refs.player if (player) { player.seekTo(fraction) @@ -48,7 +48,7 @@ export default class ReactPlayer extends Component { } this.progressTimeout = setTimeout(this.progress, PROGRESS_FREQUENCY) }; - renderPlayer = Player => { + renderPlayer = (Player) => { const active = Player.canPlay(this.props.url) const { youtubeConfig, soundcloudConfig, vimeoConfig, ...activeProps } = this.props const props = active ? { ...activeProps, ref: 'player' } : {} @@ -69,7 +69,7 @@ export default class ReactPlayer extends Component { } return (
- { players.map(this.renderPlayer) } + {players.map(this.renderPlayer)}
) } diff --git a/src/demo/App.js b/src/demo/App.js index e53097b9..18e0e3b6 100644 --- a/src/demo/App.js +++ b/src/demo/App.js @@ -17,7 +17,7 @@ export default class App extends Component { loaded: 0, duration: 0 }; - load = url => { + load = (url) => { this.setState({ url, played: 0, @@ -30,20 +30,20 @@ export default class App extends Component { stop = () => { this.setState({ url: null, playing: false }) }; - setVolume = e => { + setVolume = (e) => { this.setState({ volume: parseFloat(e.target.value) }) }; - onSeekMouseDown = e => { + onSeekMouseDown = (e) => { this.setState({ seeking: true }) }; - onSeekChange = e => { + onSeekChange = (e) => { this.setState({ played: parseFloat(e.target.value) }) }; - onSeekMouseUp = e => { + onSeekMouseUp = (e) => { this.setState({ seeking: false }) this.refs.player.seekTo(parseFloat(e.target.value)) }; - onProgress = state => { + onProgress = (state) => { // We only want to update time slider if we are not currently seeking if (!this.state.seeking) { this.setState(state) @@ -62,7 +62,7 @@ export default class App extends Component { renderLoadButton = (url, label) => { return ( ) }; @@ -94,9 +94,9 @@ export default class App extends Component { onPause={() => this.setState({ playing: false })} onBuffer={() => console.log('onBuffer')} onEnded={() => this.setState({ playing: false })} - onError={e => console.log('onError', e)} + onError={(e) => console.log('onError', e)} onProgress={this.onProgress} - onDuration={duration => this.setState({ duration })} + onDuration={(duration) => this.setState({ duration })} /> @@ -140,30 +140,30 @@ export default class App extends Component { @@ -187,23 +187,23 @@ export default class App extends Component {
YouTube - { this.renderLoadButton('https://www.youtube.com/watch?v=oUFJJNQGwhk', 'Test A') } - { this.renderLoadButton('https://www.youtube.com/watch?v=jNgP6d9HraI', 'Test B') } + {this.renderLoadButton('https://www.youtube.com/watch?v=oUFJJNQGwhk', 'Test A')} + {this.renderLoadButton('https://www.youtube.com/watch?v=jNgP6d9HraI', 'Test B')}
SoundCloud - { this.renderLoadButton('https://soundcloud.com/miami-nights-1984/accelerated', 'Test A') } - { this.renderLoadButton('https://soundcloud.com/bonobo/flashlight', 'Test B') } + {this.renderLoadButton('https://soundcloud.com/miami-nights-1984/accelerated', 'Test A')} + {this.renderLoadButton('https://soundcloud.com/bonobo/flashlight', 'Test B')}
Vimeo - { this.renderLoadButton('https://vimeo.com/90509568', 'Test A') } - { this.renderLoadButton('https://vimeo.com/94502406', 'Test B') } + {this.renderLoadButton('https://vimeo.com/90509568', 'Test A')} + {this.renderLoadButton('https://vimeo.com/94502406', 'Test B')}
Files - { this.renderLoadButton('http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4', 'MP4') } - { this.renderLoadButton('http://clips.vorwaerts-gmbh.de/big_buck_bunny.ogv', 'OGV') } - { this.renderLoadButton('http://clips.vorwaerts-gmbh.de/big_buck_bunny.webm', 'WEBM') } + {this.renderLoadButton('http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4', 'MP4')} + {this.renderLoadButton('http://clips.vorwaerts-gmbh.de/big_buck_bunny.ogv', 'OGV')} + {this.renderLoadButton('http://clips.vorwaerts-gmbh.de/big_buck_bunny.webm', 'WEBM')}
- + - + - + - + - + diff --git a/src/demo/Duration.js b/src/demo/Duration.js index 77e73593..df9ddfb0 100644 --- a/src/demo/Duration.js +++ b/src/demo/Duration.js @@ -3,7 +3,7 @@ import React from 'react' export default function Duration ({ className, seconds }) { return ( ) } diff --git a/src/players/Base.js b/src/players/Base.js index 6facfc8b..a9d5ee98 100644 --- a/src/players/Base.js +++ b/src/players/Base.js @@ -39,7 +39,7 @@ export default class Base extends Component { // When seeking before player is ready, store value and seek later if (!this.isReady && fraction !== 0) { this.seekOnReady = fraction - setTimeout(() => this.seekOnReady = null, SEEK_ON_READY_EXPIRY) + setTimeout(() => { this.seekOnReady = null }, SEEK_ON_READY_EXPIRY) } } onPlay = () => { diff --git a/src/players/SoundCloud.js b/src/players/SoundCloud.js index 085ff39a..205b316b 100644 --- a/src/players/SoundCloud.js +++ b/src/players/SoundCloud.js @@ -29,7 +29,7 @@ export default class SoundCloud extends Base { return Promise.resolve(window[SDK_GLOBAL]) } return new Promise((resolve, reject) => { - loadScript(SDK_URL, err => { + loadScript(SDK_URL, (err) => { if (err) { reject(err) } else { @@ -44,7 +44,7 @@ export default class SoundCloud extends Base { return Promise.resolve(songData[url]) } return fetch(RESOLVE_URL + '?url=' + url + '&client_id=' + this.props.soundcloudConfig.clientId) - .then(response => { + .then((response) => { if (response.status >= 200 && response.status < 300) { songData[url] = response.json() return songData[url] @@ -57,8 +57,8 @@ export default class SoundCloud extends Base { } load (url) { this.stop() - this.getSDK().then(SC => { - this.getSongData(url).then(data => { + this.getSDK().then((SC) => { + this.getSongData(url).then((data) => { if (url !== this.props.url) { return // Abort if url changes during async requests } @@ -70,7 +70,7 @@ export default class SoundCloud extends Base { if (image) { this.setState({ image: image.replace('-large', '-t500x500') }) } - SC.stream(data.uri, player => { + SC.stream(data.uri, (player) => { this.player = player player._player.on('stateChange', this.onStateChange) this.onReady() @@ -78,7 +78,7 @@ export default class SoundCloud extends Base { }, this.props.onError) }, this.props.onError) } - onStateChange = state => { + onStateChange = (state) => { if (state === 'playing') this.onPlay() if (state === 'paused') this.props.onPause() if (state === 'loading') this.props.onBuffer() diff --git a/src/players/Vimeo.js b/src/players/Vimeo.js index b82ab313..81f71d39 100644 --- a/src/players/Vimeo.js +++ b/src/players/Vimeo.js @@ -65,7 +65,7 @@ export default class Vimeo extends Base { getFractionLoaded () { return this.fractionLoaded || null } - onMessage = e => { + onMessage = (e) => { if (!MATCH_MESSAGE_ORIGIN.test(e.origin)) return this.origin = this.origin || e.origin const data = JSON.parse(e.data) diff --git a/src/players/YouTube.js b/src/players/YouTube.js index 71860c99..5167abb2 100644 --- a/src/players/YouTube.js +++ b/src/players/YouTube.js @@ -44,7 +44,7 @@ export default class YouTube extends Base { if (previousOnReady) previousOnReady() resolve(window[SDK_GLOBAL]) } - loadScript(SDK_URL, err => { + loadScript(SDK_URL, (err) => { if (err) reject(err) }) }) @@ -63,7 +63,7 @@ export default class YouTube extends Base { return } this.loadingSDK = true - this.getSDK().then(YT => { + this.getSDK().then((YT) => { this.player = new YT.Player(this.playerId, { width: '100%', height: '100%', @@ -80,7 +80,7 @@ export default class YouTube extends Base { this.onReady() }, onStateChange: this.onStateChange, - onError: event => this.props.onError(event.data) + onError: (event) => this.props.onError(event.data) } }) }, this.props.onError) diff --git a/test/karma/ReactPlayer.js b/test/karma/ReactPlayer.js index a8d1947e..bcec9ff3 100644 --- a/test/karma/ReactPlayer.js +++ b/test/karma/ReactPlayer.js @@ -41,7 +41,7 @@ describe('ReactPlayer', () => { } const testDuration = (url, done) => { - const onDuration = duration => { + const onDuration = (duration) => { if (duration && duration > 0) done() } render(, div) @@ -52,13 +52,13 @@ describe('ReactPlayer', () => { } describe('YouTube', () => { - it('fires onPlay', done => testPlay(TEST_YOUTUBE_URL, done)) - it('fires onPause', done => testPause(TEST_YOUTUBE_URL, done)) - it('fires onDuration', done => testDuration(TEST_YOUTUBE_URL, done)) - it('fires onError', done => testError(TEST_YOUTUBE_ERROR, done)) + it('fires onPlay', (done) => testPlay(TEST_YOUTUBE_URL, done)) + it('fires onPause', (done) => testPause(TEST_YOUTUBE_URL, done)) + it('fires onDuration', (done) => testDuration(TEST_YOUTUBE_URL, done)) + it('fires onError', (done) => testError(TEST_YOUTUBE_ERROR, done)) - it('starts at a specified time', done => { - const onProgress = state => { + it('starts at a specified time', (done) => { + const onProgress = (state) => { if (state.played > 0.9) done() } render(, div) @@ -66,23 +66,23 @@ describe('ReactPlayer', () => { }) describe('SoundCloud', () => { - it('fires onPlay', done => testPlay(TEST_SOUNDCLOUD_URL, done)) - it('fires onPause', done => testPause(TEST_SOUNDCLOUD_URL, done)) - it('fires onDuration', done => testDuration(TEST_SOUNDCLOUD_URL, done)) - it('fires onError', done => testError(TEST_SOUNDCLOUD_ERROR, done)) + it('fires onPlay', (done) => testPlay(TEST_SOUNDCLOUD_URL, done)) + it('fires onPause', (done) => testPause(TEST_SOUNDCLOUD_URL, done)) + it('fires onDuration', (done) => testDuration(TEST_SOUNDCLOUD_URL, done)) + it('fires onError', (done) => testError(TEST_SOUNDCLOUD_ERROR, done)) }) describe('Vimeo', () => { - it('fires onPlay a Vimeo video', done => testPlay(TEST_VIMEO_URL, done)) - it('fires onPause a Vimeo video', done => testPause(TEST_VIMEO_URL, done)) - it('fires onDuration for Vimeo video', done => testDuration(TEST_VIMEO_URL, done)) + it('fires onPlay a Vimeo video', (done) => testPlay(TEST_VIMEO_URL, done)) + it('fires onPause a Vimeo video', (done) => testPause(TEST_VIMEO_URL, done)) + it('fires onDuration for Vimeo video', (done) => testDuration(TEST_VIMEO_URL, done)) }) describe('FilePlayer', () => { - it('fires onPlay a file', done => testPlay(TEST_FILE_URL, done)) - it('fires onPause a file', done => testPause(TEST_FILE_URL, done)) - it('fires onDuration for file', done => testDuration(TEST_FILE_URL, done)) - it('fires onError for file', done => testError(TEST_FILE_ERROR, done)) + it('fires onPlay a file', (done) => testPlay(TEST_FILE_URL, done)) + it('fires onPause a file', (done) => testPause(TEST_FILE_URL, done)) + it('fires onDuration for file', (done) => testDuration(TEST_FILE_URL, done)) + it('fires onError for file', (done) => testError(TEST_FILE_ERROR, done)) }) it('switches between media', function (done) {
url{ url || 'null' }{url || 'null'}
playing{ playing ? 'true' : 'false' }{playing ? 'true' : 'false'}
volume{ volume.toFixed(3) }{volume.toFixed(3)}
played{ played.toFixed(3) }{played.toFixed(3)}
loaded{ loaded.toFixed(3) }{loaded.toFixed(3)}
duration