From 4ebd5445b246b6594b58af226f3f4bde3f37b2b9 Mon Sep 17 00:00:00 2001 From: Vesa Luusua Date: Tue, 14 Mar 2017 13:11:17 +0200 Subject: [PATCH] First run after prettier upgrade --- .../EditListingForm/EditListingForm.js | 30 ++++----- src/containers/LandingPage/LandingPage.js | 7 +- src/containers/SearchPage/SearchPage.duck.js | 23 ++++--- src/sagas.js | 7 +- src/util/googleMaps.js | 64 +++++++++---------- src/util/sagaHelpers.js | 17 +++-- src/util/validators.js | 14 ++-- 7 files changed, 74 insertions(+), 88 deletions(-) diff --git a/src/containers/EditListingForm/EditListingForm.js b/src/containers/EditListingForm/EditListingForm.js index b2d69d77..34a5e1af 100644 --- a/src/containers/EditListingForm/EditListingForm.js +++ b/src/containers/EditListingForm/EditListingForm.js @@ -11,17 +11,16 @@ const TITLE_MAX_LENGTH = 60; // readImage returns a promise which is resolved // when FileReader has loaded given file as dataURL -const readImage = file => - new Promise((resolve, reject) => { - const reader = new FileReader(); - reader.onload = e => resolve(e.target.result); - reader.onerror = e => { - // eslint-disable-next-line - console.error(`Error ${e} happened while reading ${file.name}: ${e.target.result}`); - reject(new Error(`Error reading ${file.name}: ${e.target.result}`)); - }; - reader.readAsDataURL(file); - }); +const readImage = file => new Promise((resolve, reject) => { + const reader = new FileReader(); + reader.onload = e => resolve(e.target.result); + reader.onerror = e => { + // eslint-disable-next-line + console.error(`Error ${e} happened while reading ${file.name}: ${e.target.result}`); + reject(new Error(`Error reading ${file.name}: ${e.target.result}`)); + }; + reader.readAsDataURL(file); +}); // Custom inputs with validator messages const RenderField = ({ input, label, type, meta }) => { @@ -119,12 +118,9 @@ class EditListingForm extends Component { submitting, } = this.props; const requiredStr = intl.formatMessage({ id: 'EditListingForm.required' }); - const maxLengthStr = intl.formatMessage( - { id: 'EditListingForm.maxLength' }, - { - maxLength: TITLE_MAX_LENGTH, - }, - ); + const maxLengthStr = intl.formatMessage({ id: 'EditListingForm.maxLength' }, { + maxLength: TITLE_MAX_LENGTH, + }); const maxLength60 = maxLength(maxLengthStr, TITLE_MAX_LENGTH); const imageRequiredStr = intl.formatMessage({ id: 'EditListingForm.imageRequired' }); diff --git a/src/containers/LandingPage/LandingPage.js b/src/containers/LandingPage/LandingPage.js index d951484c..26c02c9e 100644 --- a/src/containers/LandingPage/LandingPage.js +++ b/src/containers/LandingPage/LandingPage.js @@ -5,10 +5,9 @@ import { HeroSearchForm } from '../../containers'; import { changeLocationFilter } from '../../ducks/LocationFilter.duck'; import css from './LandingPage.css'; -const createSubmitHandler = onLocationChanged => - formData => { - onLocationChanged(formData.location); - }; +const createSubmitHandler = onLocationChanged => formData => { + onLocationChanged(formData.location); +}; export const LandingPageComponent = props => { const { onLocationChanged, filter } = props; diff --git a/src/containers/SearchPage/SearchPage.duck.js b/src/containers/SearchPage/SearchPage.duck.js index 76caf833..4c1955fc 100644 --- a/src/containers/SearchPage/SearchPage.duck.js +++ b/src/containers/SearchPage/SearchPage.duck.js @@ -80,20 +80,19 @@ export const loadListings = { # { id: 123, type: 'user', attributes: { name: "John" }}, ``` */ -const lookupMap = included => - included.reduce( - (memo, resource) => { - const { type, id } = resource; +const lookupMap = included => included.reduce( + (memo, resource) => { + const { type, id } = resource; - // eslint-disable-next-line no-param-reassign - memo[type] = memo[type] || {}; - // eslint-disable-next-line no-param-reassign - memo[type][id.uuid] = resource; + // eslint-disable-next-line no-param-reassign + memo[type] = memo[type] || {}; + // eslint-disable-next-line no-param-reassign + memo[type][id.uuid] = resource; - return memo; - }, - {}, - ); + return memo; + }, + {}, +); // Format the data as ListingCard component expects it and // add some fake data diff --git a/src/sagas.js b/src/sagas.js index 6698de74..8dfa8e69 100644 --- a/src/sagas.js +++ b/src/sagas.js @@ -2,9 +2,8 @@ import { watchAuthInfo, watchAuth } from './ducks/Auth.duck'; import { watchLoadListings } from './containers/SearchPage/SearchPage.duck'; import { watchSdk } from './ducks/sdk.duck'; -const createRootSaga = sdk => - function* rootSaga() { - yield [watchAuthInfo(sdk), watchAuth(sdk), watchLoadListings(sdk), watchSdk(sdk)]; - }; +const createRootSaga = sdk => function* rootSaga() { + yield [watchAuthInfo(sdk), watchAuth(sdk), watchLoadListings(sdk), watchSdk(sdk)]; +}; export default createRootSaga; diff --git a/src/util/googleMaps.js b/src/util/googleMaps.js index 532bf50f..018b9f6b 100644 --- a/src/util/googleMaps.js +++ b/src/util/googleMaps.js @@ -30,28 +30,25 @@ const placeBounds = place => { * @return {Promise} Promise that * resolves to the detailed place, rejects if the request failed */ -export const getPlaceDetails = placeId => - new Promise((resolve, reject) => { - const serviceStatus = window.google.maps.places.PlacesServiceStatus; - const el = document.createElement('div'); - const service = new window.google.maps.places.PlacesService(el); +export const getPlaceDetails = placeId => new Promise((resolve, reject) => { + const serviceStatus = window.google.maps.places.PlacesServiceStatus; + const el = document.createElement('div'); + const service = new window.google.maps.places.PlacesService(el); - service.getDetails({ placeId }, (place, status) => { - if (status !== serviceStatus.OK) { - reject( - new Error( - `Could not get details for place id "${placeId}", error status was "${status}"`, - ), - ); - } else { - resolve({ - address: place.formatted_address, - origin: placeOrigin(place), - bounds: placeBounds(place), - }); - } - }); + service.getDetails({ placeId }, (place, status) => { + if (status !== serviceStatus.OK) { + reject( + new Error(`Could not get details for place id "${placeId}", error status was "${status}"`), + ); + } else { + resolve({ + address: place.formatted_address, + origin: placeOrigin(place), + bounds: placeBounds(place), + }); + } }); +}); const predictionSuccessful = status => { const { OK, ZERO_RESULTS } = window.google.maps.places.PlacesServiceStatus; @@ -67,19 +64,18 @@ const predictionSuccessful = status => { * with the original search query and an array of * `google.maps.places.AutocompletePrediction` objects */ -export const getPlacePredictions = search => - new Promise((resolve, reject) => { - const service = new window.google.maps.places.AutocompleteService(); +export const getPlacePredictions = search => new Promise((resolve, reject) => { + const service = new window.google.maps.places.AutocompleteService(); - service.getPlacePredictions({ input: search }, (predictions, status) => { - if (!predictionSuccessful(status)) { - reject(new Error(`Prediction service status not OK: ${status}`)); - } else { - const results = { - search, - predictions: predictions || [], - }; - resolve(results); - } - }); + service.getPlacePredictions({ input: search }, (predictions, status) => { + if (!predictionSuccessful(status)) { + reject(new Error(`Prediction service status not OK: ${status}`)); + } else { + const results = { + search, + predictions: predictions || [], + }; + resolve(results); + } }); +}); diff --git a/src/util/sagaHelpers.js b/src/util/sagaHelpers.js index d9546990..17c1220a 100644 --- a/src/util/sagaHelpers.js +++ b/src/util/sagaHelpers.js @@ -6,13 +6,12 @@ const SUCCESS = 'SUCCESS'; const FAILURE = 'FAILURE'; // response format: { REQUEST: 'baseStr.REQUEST', SUCCESS: 'baseStr.SUCCESS', FAILURE: 'baseStr.FAILURE' } -export const createRequestTypes = base => - [REQUEST, SUCCESS, FAILURE].reduce( - (acc, type) => { - // eslint-disable-next-line no-param-reassign - acc[type] = `${base}.${type}`; - return acc; - }, - {}, - ); +export const createRequestTypes = base => [REQUEST, SUCCESS, FAILURE].reduce( + (acc, type) => { + // eslint-disable-next-line no-param-reassign + acc[type] = `${base}.${type}`; + return acc; + }, + {}, +); /* eslint-enable import/prefer-default-export */ diff --git a/src/util/validators.js b/src/util/validators.js index de23ca4b..b65d3f0e 100644 --- a/src/util/validators.js +++ b/src/util/validators.js @@ -5,15 +5,13 @@ // Redux Form expects and undefined value for a successful validation const VALID = undefined; -export const required = message => - value => { - return value ? VALID : message; - }; +export const required = message => value => { + return value ? VALID : message; +}; -export const maxLength = (message, maximumLength) => - value => { - return !value || value.length <= maximumLength ? VALID : message; - }; +export const maxLength = (message, maximumLength) => value => { + return !value || value.length <= maximumLength ? VALID : message; +}; export const noEmptyArray = message => value => { return value && Array.isArray(value) && value.length > 0 ? VALID : message;