From a0d224ca9c984d7185f65882f90279852510fb74 Mon Sep 17 00:00:00 2001 From: Lachlan Kermode Date: Thu, 15 Aug 2019 11:24:54 +0100 Subject: [PATCH] lint it --- package.json | 3 +- src/common/global.js | 15 ++- src/components/InfoPopup.jsx | 11 +- src/components/Map.jsx | 6 +- src/components/Overlay/Media.js | 101 +++++++++--------- src/components/presentational/Map/Events.jsx | 32 +++--- .../presentational/Timeline/ZoomControls.js | 4 +- .../presentational/covers/TemplateCover.js | 73 +++++++------ 8 files changed, 121 insertions(+), 124 deletions(-) diff --git a/package.json b/package.json index 6b8bc80..b31c19f 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "build": "NODE_ENV=production webpack --mode production", "test": "ava --verbose", "test-watch": "ava --watch", - "lint": "standard \"src/**/*.js\" \"src/**/*.jsx\" \"test/**/*.js\"" + "lint": "standard \"src/**/*.js\" \"src/**/*.jsx\" \"test/**/*.js\"", + "lint:fix": "npm run lint -- --fix" }, "dependencies": { "babel-polyfill": "^6.26.0", diff --git a/src/common/global.js b/src/common/global.js index b88f71f..a0165ce 100644 --- a/src/common/global.js +++ b/src/common/global.js @@ -1,13 +1,12 @@ - const colors = { - fa_red : '#eb443e', - yellow : '#ffd800', - black : '#000', - white : '#fff' + fa_red: '#eb443e', + yellow: '#ffd800', + black: '#000', + white: '#fff' } export default { - darkBackground : colors.black, - primaryHighlight : colors.yellow, - secondaryHighlight : colors.white + darkBackground: colors.black, + primaryHighlight: colors.yellow, + secondaryHighlight: colors.white } diff --git a/src/components/InfoPopup.jsx b/src/components/InfoPopup.jsx index 663b498..cba5e89 100644 --- a/src/components/InfoPopup.jsx +++ b/src/components/InfoPopup.jsx @@ -24,9 +24,9 @@ export default ({ ui, app, methods }) => { , - - - 2 + + + 2 ] @@ -61,7 +61,6 @@ export default ({ ui, app, methods }) => { } function renderView2DLegend () { - const categories = Object.keys(ui.style.categories).filter(label => label !== 'default') return (
@@ -83,7 +82,7 @@ export default ({ ui, app, methods }) => {
-
+

In narrative mode, arrows indicate physical movement between two events.

@@ -91,7 +90,7 @@ export default ({ ui, app, methods }) => { { ui.style.arrows ? ( - Object.keys(ui.style.arrows).map( arrowName => ( + Object.keys(ui.style.arrows).map(arrowName => (
{renderArrow(ui.style.arrows[arrowName])}
diff --git a/src/components/Map.jsx b/src/components/Map.jsx index 4aa0b18..7c9f0a1 100644 --- a/src/components/Map.jsx +++ b/src/components/Map.jsx @@ -52,9 +52,9 @@ class Map extends React.Component { if (eventPoint !== null && eventPoint.latitude && eventPoint.longitude) { // this.map.setView([eventPoint.latitude, eventPoint.longitude]) this.map.setView([eventPoint.latitude, eventPoint.longitude], this.map.getZoom(), { - "animate":true, - "pan":{ - "duration": 0.7 + 'animate': true, + 'pan': { + 'duration': 0.7 } }) } diff --git a/src/components/Overlay/Media.js b/src/components/Overlay/Media.js index f48104d..c5d7146 100644 --- a/src/components/Overlay/Media.js +++ b/src/components/Overlay/Media.js @@ -29,64 +29,64 @@ class SourceOverlay extends React.Component { } switchToTrans (idx) { - this.setState({ transIdx: idx }); + this.setState({ transIdx: idx }) } - renderContent(source) { + renderContent (source) { const { url, title, paths, date, type, desc, poster } = source const shortenedTitle = title.substring(0, 100) return ( -
-
- close -
- -

{shortenedTitle}

- -
- {this.props.translations ? this.props.translations.map((trans, idx) => ( - this.state.transIdx !== idx + 1 ? ( -
this.switchToTrans(idx + 1)}>{trans.code}
- ) : ( -
this.switchToTrans(0)}>EN
- ) - )) : null} -
-
-
e.stopPropagation()}> -
- selectTypeFromPathWithPoster(p, poster))} viewmediaIdx={this.state.mediaIdx} /> -
-
- -
- - -
-
-
{desc}
+
+
+ close
- {(type || date || url) ? ( -
-
- {type ?

Evidence type

: null} - {type ?

perm_media{type}

: null} -
-
- {date ?

Date Published

: null} - {date ?

today{date}

: null} -
-
- {url ?

Link

: null} - {url ? linkLink to original URL : null} -
-
- ) : null} +

{shortenedTitle}

+ +
+ {this.props.translations ? this.props.translations.map((trans, idx) => ( + this.state.transIdx !== idx + 1 ? ( +
this.switchToTrans(idx + 1)}>{trans.code}
+ ) : ( +
this.switchToTrans(0)}>EN
+ ) + )) : null} +
-
- +
e.stopPropagation()}> +
+ selectTypeFromPathWithPoster(p, poster))} viewmediaIdx={this.state.mediaIdx} /> +
+
+ +
+ + +
+
+
{desc}
+
+ + {(type || date || url) ? ( +
+
+ {type ?

Evidence type

: null} + {type ?

perm_media{type}

: null} +
+
+ {date ?

Date Published

: null} + {date ?

today{date}

: null} +
+
+ {url ?

Link

: null} + {url ? linkLink to original URL : null} +
+
+ ) : null} +
+
+ ) } @@ -94,12 +94,11 @@ class SourceOverlay extends React.Component { if (typeof (this.props.source) !== 'object') { return this.renderError() } - const { url, title, paths, date, type, desc, poster } = this.props.source const { transIdx } = this.state return (
- {this.renderContent(transIdx === 0 ? this.props.source : this.props.translations[transIdx-1])} + {this.renderContent(transIdx === 0 ? this.props.source : this.props.translations[transIdx - 1])}
) } diff --git a/src/components/presentational/Map/Events.jsx b/src/components/presentational/Map/Events.jsx index e459240..9fc557d 100644 --- a/src/components/presentational/Map/Events.jsx +++ b/src/components/presentational/Map/Events.jsx @@ -9,16 +9,16 @@ function MapEvents ({ getCategoryColor, categories, projectPoint, styleLocation, return [x, y] } - function renderBorder() { + function renderBorder () { return ( {} ) @@ -110,20 +110,20 @@ function MapEvents ({ getCategoryColor, categories, projectPoint, styleLocation, const customStyles = styleLocation ? styleLocation(location) : null const extraRender = (customStyles) ? customStyles[1] : null - const isSelected = selected.reduce( (acc, event) => { - return acc || (event.latitude == location.latitude && event.longitude == location.longitude) + const isSelected = selected.reduce((acc, event) => { + return acc || (event.latitude === location.latitude && event.longitude === location.longitude) }, false) return ( - onSelect(location.events) : null} - > - {renderLocationSlicesByCategory(location)} - {extraRender ? extraRender() : null} - {isSelected ? null : renderBorder()} - + onSelect(location.events) : null} + > + {renderLocationSlicesByCategory(location)} + {extraRender ? extraRender() : null} + {isSelected ? null : renderBorder()} + ) } diff --git a/src/components/presentational/Timeline/ZoomControls.js b/src/components/presentational/Timeline/ZoomControls.js index 98c2309..1e551f1 100644 --- a/src/components/presentational/Timeline/ZoomControls.js +++ b/src/components/presentational/Timeline/ZoomControls.js @@ -1,8 +1,8 @@ import React from 'react' -function zoomIsActive(duration, extent) { +function zoomIsActive (duration, extent) { if (duration > 1570000 && extent > 1570000) { - return true; + return true } return duration === extent } diff --git a/src/components/presentational/covers/TemplateCover.js b/src/components/presentational/covers/TemplateCover.js index ed18dc7..c4b2c8c 100644 --- a/src/components/presentational/covers/TemplateCover.js +++ b/src/components/presentational/covers/TemplateCover.js @@ -1,11 +1,10 @@ import React from 'react' -import { connect } from "react-redux" +import { connect } from 'react-redux' import MediaOverlay from '../../Overlay/Media' const ReactMarkdown = require('react-markdown') const MEDIA_HIDDEN = -2 -const MEDIA_HOWTO = -1 class TemplateCover extends React.Component { constructor (props) { @@ -15,10 +14,10 @@ class TemplateCover extends React.Component { } } - getVideo(index, headerEndIndex) { - if(index < headerEndIndex) { + getVideo (index, headerEndIndex) { + if (index < headerEndIndex) { return this.props.cover.headerVideos[index] - } else if(index >= 0) { + } else if (index >= 0) { return this.props.cover.videos[index] } else { return null @@ -30,7 +29,7 @@ class TemplateCover extends React.Component { var video = this.getVideo(this.state.video, headerVideos.length || 0) return (
-
+
{ this.props.cover.bgVideo ? (
@@ -41,7 +40,7 @@ class TemplateCover extends React.Component { preload='auto' className='fullscreen-bg__video' > - +
) : null @@ -55,17 +54,17 @@ class TemplateCover extends React.Component { }
- { - headerVideos ? ( -
- { headerVideos.slice(0,2).map( (media, index) => ( -
this.setState({ video: index })}> - {media.buttonTitle} -
- ) ) } -
- ) : null - } + { + headerVideos ? ( +
+ { headerVideos.slice(0, 2).map((media, index) => ( +
this.setState({ video: index })}> + {media.buttonTitle} +
+ )) } +
+ ) : null + }
EXPLORE @@ -80,8 +79,8 @@ class TemplateCover extends React.Component {
{/* NOTE: only take first four videos, drop any others for style reasons */} - { this.props.cover.videos.slice(0,4).map( (media, index) => ( -
this.setState({ video: index + (headerVideos.length || 0)})} > + { this.props.cover.videos.slice(0, 4).map((media, index) => ( +
this.setState({ video: index + (headerVideos.length || 0) })} > {media.buttonTitle}
{media.buttonSubtitle}
)) } @@ -92,29 +91,29 @@ class TemplateCover extends React.Component {
{ - this.state.video != MEDIA_HIDDEN ? ( - this.setState({ video: MEDIA_HIDDEN })} - /> - ) : null } + this.state.video !== MEDIA_HIDDEN ? ( + this.setState({ video: MEDIA_HIDDEN })} + /> + ) : null }
) } } -function mapStateToProps(state) { +function mapStateToProps (state) { return { - cover : state.app.cover + cover: state.app.cover } } -export default connect(mapStateToProps) (TemplateCover); +export default connect(mapStateToProps)(TemplateCover)