Update Prettier to 1.15.3

This commit is contained in:
Jenni Nurmi 2018-11-29 10:18:43 +02:00
parent 1fa91f7cf7
commit 0aca4567c2
42 changed files with 222 additions and 123 deletions

View file

@ -3,7 +3,7 @@
The following configuration variables can be set to control the Flex template app behaviour. Most of
them have defaults that work for development environment. For production deploys most should be set.
| Variable | Description |
| Variable | Description |
| ----------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| REACT_APP_MAPBOX_ACCESS_TOKEN | See: [Integrating to map providers](./map-providers.md) |
| REACT_APP_GOOGLE_MAPS_API_KEY | See: [Google Maps API key](./google-maps.md) (Alternative map provider) |
@ -24,7 +24,7 @@ them have defaults that work for development environment. For production deploys
| REACT_APP_GOOGLE_ANALYTICS_ID | See: [Google Analytics](./analytics.md) |
| REACT_APP_AVAILABILITY_ENABLED | Enables availability calendar for listings. |
| REACT_APP_DEFAULT_SEARCHES_ENABLED | Enables default search suggestions in location autocomplete search input. |
| REACT_APP_SHARETRIBE_SDK_BASE_URL | The base url to access the Sharetribe Flex Marketplace API. FTW uses the correct one by default so no need to set this. |
| REACT_APP_SHARETRIBE_SDK_BASE_URL | The base url to access the Sharetribe Flex Marketplace API. FTW uses the correct one by default so no need to set this. |
## Defining configuration

View file

@ -67,16 +67,16 @@ comments.
_public/index.html:_
```html
<script src="%PUBLIC_URL%/static/scripts/mapbox/mapbox-sdk.min.js"></script>
<link href="https://api.mapbox.com/mapbox-gl-js/v0.47.0/mapbox-gl.css" rel="stylesheet" />
<script src="https://api.mapbox.com/mapbox-gl-js/v0.47.0/mapbox-gl.js"></script>
<script>
window.mapboxgl.accessToken = '%REACT_APP_MAPBOX_ACCESS_TOKEN%';
</script>
<!--
If Google Maps is used instead of Mapbox, you need to include Google's script instead:
<script src="https://maps.googleapis.com/maps/api/js?key=%REACT_APP_GOOGLE_MAPS_API_KEY%&libraries=places"></script>
-->
<script src="%PUBLIC_URL%/static/scripts/mapbox/mapbox-sdk.min.js"></script>
<link href="https://api.mapbox.com/mapbox-gl-js/v0.47.0/mapbox-gl.css" rel="stylesheet" />
<script src="https://api.mapbox.com/mapbox-gl-js/v0.47.0/mapbox-gl.js"></script>
<script>
window.mapboxgl.accessToken = '%REACT_APP_MAPBOX_ACCESS_TOKEN%';
</script>
<!--
If Google Maps is used instead of Mapbox, you need to include Google's script instead:
<script src="https://maps.googleapis.com/maps/api/js?key=%REACT_APP_GOOGLE_MAPS_API_KEY%&libraries=places"></script>
-->
```
### 2. Searching with Google's geocoding API

View file

@ -28,15 +28,15 @@ set if icons and an HTML snippet to point to those images.
**Example HTML snippet:**
```html
<!-- Start Favicons from https://realfavicongenerator.net/ -->
<link rel="apple-touch-icon" sizes="180x180" href="/static/icons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/static/icons/favicon-16x16.png">
<link rel="mask-icon" href="/static/icons/safari-pinned-tab.svg" color="#c0392b">
<link rel="shortcut icon" href="/static/icons/favicon.ico">
<meta name="msapplication-config" content="/static/icons/browserconfig.xml">
<meta name="theme-color" content="#c0392b">
<!-- End Favicons -->
<!-- Start Favicons from https://realfavicongenerator.net/ -->
<link rel="apple-touch-icon" sizes="180x180" href="/static/icons/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/static/icons/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/static/icons/favicon-16x16.png" />
<link rel="mask-icon" href="/static/icons/safari-pinned-tab.svg" color="#c0392b" />
<link rel="shortcut icon" href="/static/icons/favicon.ico" />
<meta name="msapplication-config" content="/static/icons/browserconfig.xml" />
<meta name="theme-color" content="#c0392b" />
<!-- End Favicons -->
```
## Map marker icon

View file

@ -64,7 +64,7 @@
"nodemon": "^1.17.2",
"nsp": "^3.2.1",
"nsp-preprocessor-yarn": "^1.0.1",
"prettier": "^1.11.1"
"prettier": "^1.15.3"
},
"scripts": {
"clean": "rm -rf build/*",

View file

@ -187,4 +187,7 @@ const mapStateToProps = state => {
// lifecycle hook.
//
// See: https://github.com/ReactTraining/react-router/issues/4671
export default compose(withRouter, connect(mapStateToProps))(Routes);
export default compose(
withRouter,
connect(mapStateToProps)
)(Routes);

View file

@ -12,8 +12,8 @@ const LineItemUnitPrice = props => {
const translationKey = isNightly
? 'BookingBreakdown.pricePerNight'
: isDaily
? 'BookingBreakdown.pricePerDay'
: 'BookingBreakdown.pricePerQuantity';
? 'BookingBreakdown.pricePerDay'
: 'BookingBreakdown.pricePerQuantity';
const unitPurchase = transaction.attributes.lineItems.find(
item => item.code === unitType && !item.reversal

View file

@ -43,7 +43,11 @@ class Discussion extends Component {
render() {
return (
<div className={this.props.className}>
<ul>{this.props.messages.map(msg => <Message key={msg.id} {...msg} />)}</ul>
<ul>
{this.props.messages.map(msg => (
<Message key={msg.id} {...msg} />
))}
</ul>
<form className={css.sendMessageForm} onSubmit={this.handleNewMessage}>
<input
className={css.sendMessageInput}

View file

@ -327,4 +327,7 @@ EditListingWizard.propTypes = {
intl: intlShape.isRequired,
};
export default compose(withViewport, injectIntl)(EditListingWizard);
export default compose(
withViewport,
injectIntl
)(EditListingWizard);

View file

@ -44,8 +44,8 @@ const ListingLink = props => {
const variant = isPendingApproval
? LISTING_PAGE_PENDING_APPROVAL_VARIANT
: isDraft
? LISTING_PAGE_DRAFT_VARIANT
: null;
? LISTING_PAGE_DRAFT_VARIANT
: null;
const linkProps = !!variant
? {
name: 'ListingPageVariant',

View file

@ -68,8 +68,8 @@ const createListingURL = (routes, listing) => {
const variant = isDraft
? LISTING_PAGE_DRAFT_VARIANT
: isPendingApproval
? LISTING_PAGE_PENDING_APPROVAL_VARIANT
: null;
? LISTING_PAGE_PENDING_APPROVAL_VARIANT
: null;
const linkProps =
isPendingApproval || isDraft
@ -359,4 +359,7 @@ ManageListingCardComponent.propTypes = {
}).isRequired,
};
export default compose(withRouter, injectIntl)(ManageListingCardComponent);
export default compose(
withRouter,
injectIntl
)(ManageListingCardComponent);

View file

@ -91,8 +91,8 @@ class StaticGoogleMap extends Component {
const targetMaybe = mapsConfig.fuzzy.enabled
? { path: drawFuzzyCircle(mapsConfig, center) }
: mapsConfig.customMarker.enabled
? { markers: customMarker(mapsConfig.customMarker, lat, lng) }
: { markers: `${lat},${lng}` };
? { markers: customMarker(mapsConfig.customMarker, lat, lng) }
: { markers: `${lat},${lng}` };
const srcParams = stringify({
center: encodeLatLng(center),

View file

@ -33,14 +33,14 @@ class RangeSliderComponent extends Component {
const width = dimensions.width;
const valueOffset = value - min;
const scale = max - min;
return Math.round(valueOffset / scale * width);
return Math.round((valueOffset / scale) * width);
}
toValue(position) {
const { dimensions, min, max, step } = this.props;
const width = dimensions.width;
const scale = max - min;
const value = Math.round(position / width * scale) + min;
const value = Math.round((position / width) * scale) + min;
return Math.ceil(value / step) * step;
}

View file

@ -229,6 +229,9 @@ SearchFiltersComponent.propTypes = {
intl: intlShape.isRequired,
};
const SearchFilters = compose(withRouter, injectIntl)(SearchFiltersComponent);
const SearchFilters = compose(
withRouter,
injectIntl
)(SearchFiltersComponent);
export default SearchFilters;

View file

@ -148,8 +148,8 @@ const priceLabelsInLocations = (
const infoCardOpenIds = Array.isArray(infoCardOpen)
? infoCardOpen.map(l => l.id.uuid)
: infoCardOpen
? [infoCardOpen.id.uuid]
: [];
? [infoCardOpen.id.uuid]
: [];
// if the listing is open, don't print price label
if (infoCardOpen != null && infoCardOpenIds.includes(listing.id.uuid)) {
@ -400,22 +400,24 @@ class SearchMapWithMapbox extends Component {
// SearchMapPriceLabel and SearchMapGroupLabel:
// create a new marker or use existing one if markerId is among previously rendered markers
this.currentMarkers = labels.filter(v => v != null).map(m => {
const existingMarkerId = this.currentMarkers.findIndex(
marker => m.markerId === marker.markerId && marker.marker
);
this.currentMarkers = labels
.filter(v => v != null)
.map(m => {
const existingMarkerId = this.currentMarkers.findIndex(
marker => m.markerId === marker.markerId && marker.marker
);
if (existingMarkerId >= 0) {
const { marker, markerContainer, ...rest } = this.currentMarkers[existingMarkerId];
return { ...rest, ...m, markerContainer, marker };
} else {
const markerContainer = document.createElement('div');
markerContainer.setAttribute('id', m.markerId);
markerContainer.classList.add(css.labelContainer);
const marker = createMarker(m, markerContainer);
return { ...m, markerContainer, marker };
}
});
if (existingMarkerId >= 0) {
const { marker, markerContainer, ...rest } = this.currentMarkers[existingMarkerId];
return { ...rest, ...m, markerContainer, marker };
} else {
const markerContainer = document.createElement('div');
markerContainer.setAttribute('id', m.markerId);
markerContainer.classList.add(css.labelContainer);
const marker = createMarker(m, markerContainer);
return { ...m, markerContainer, marker };
}
});
/* Create marker for SearchMapInfoCard component */
if (infoCardOpen) {

View file

@ -326,7 +326,10 @@ TopbarComponent.propTypes = {
intl: intlShape.isRequired,
};
const Topbar = compose(withViewport, injectIntl)(TopbarComponent);
const Topbar = compose(
withViewport,
injectIntl
)(TopbarComponent);
Topbar.displayName = 'Topbar';

View file

@ -100,8 +100,8 @@ export const AddressLinkMaybe = props => {
const hrefToGoogleMaps = geolocation
? `https://maps.google.com/?q=${lat},${lng}`
: address
? `https://maps.google.com/?q=${encodeURIComponent(address)}`
: null;
? `https://maps.google.com/?q=${encodeURIComponent(address)}`
: null;
const fullAddress =
typeof building === 'string' && building.length > 0 ? `${building}, ${address}` : address;

View file

@ -324,7 +324,10 @@ const mapDispatchToProps = dispatch => ({
// See: https://github.com/ReactTraining/react-router/issues/4671
const AuthenticationPage = compose(
withRouter,
connect(mapStateToProps, mapDispatchToProps),
connect(
mapStateToProps,
mapDispatchToProps
),
injectIntl
)(AuthenticationPageComponent);

View file

@ -532,9 +532,14 @@ const mapDispatchToProps = dispatch => ({
fetchSpeculatedTransaction: params => dispatch(speculateTransaction(params)),
});
const CheckoutPage = compose(withRouter, connect(mapStateToProps, mapDispatchToProps), injectIntl)(
CheckoutPageComponent
);
const CheckoutPage = compose(
withRouter,
connect(
mapStateToProps,
mapDispatchToProps
),
injectIntl
)(CheckoutPageComponent);
CheckoutPage.setInitialValues = initialValues => setInitialValues(initialValues);

View file

@ -167,9 +167,13 @@ const mapDispatchToProps = dispatch => ({
onSubmitContactDetails: values => dispatch(saveContactDetails(values)),
});
const ContactDetailsPage = compose(connect(mapStateToProps, mapDispatchToProps), injectIntl)(
ContactDetailsPageComponent
);
const ContactDetailsPage = compose(
connect(
mapStateToProps,
mapDispatchToProps
),
injectIntl
)(ContactDetailsPageComponent);
ContactDetailsPage.loadData = () => {
// Since verify email happens in separate tab, current user's data might be updated

View file

@ -271,9 +271,13 @@ const mapDispatchToProps = dispatch => ({
// lifecycle hook.
//
// See: https://github.com/ReactTraining/react-router/issues/4671
const EditListingPage = compose(withRouter, connect(mapStateToProps, mapDispatchToProps))(
injectIntl(EditListingPageComponent)
);
const EditListingPage = compose(
withRouter,
connect(
mapStateToProps,
mapDispatchToProps
)
)(injectIntl(EditListingPageComponent));
EditListingPage.loadData = loadData;

View file

@ -138,7 +138,10 @@ const mapDispatchToProps = dispatch => ({
// See: https://github.com/ReactTraining/react-router/issues/4671
const EmailVerificationPage = compose(
withRouter,
connect(mapStateToProps, mapDispatchToProps),
connect(
mapStateToProps,
mapDispatchToProps
),
injectIntl
)(EmailVerificationPageComponent);

View file

@ -419,7 +419,10 @@ const mapStateToProps = state => {
};
};
const InboxPage = compose(connect(mapStateToProps), injectIntl)(InboxPageComponent);
const InboxPage = compose(
connect(mapStateToProps),
injectIntl
)(InboxPageComponent);
InboxPage.loadData = loadData;

View file

@ -107,6 +107,10 @@ const mapStateToProps = state => {
// lifecycle hook.
//
// See: https://github.com/ReactTraining/react-router/issues/4671
const LandingPage = compose(withRouter, connect(mapStateToProps), injectIntl)(LandingPageComponent);
const LandingPage = compose(
withRouter,
connect(mapStateToProps),
injectIntl
)(LandingPageComponent);
export default LandingPage;

View file

@ -620,9 +620,14 @@ const mapDispatchToProps = dispatch => ({
// lifecycle hook.
//
// See: https://github.com/ReactTraining/react-router/issues/4671
const ListingPage = compose(withRouter, connect(mapStateToProps, mapDispatchToProps), injectIntl)(
ListingPageComponent
);
const ListingPage = compose(
withRouter,
connect(
mapStateToProps,
mapDispatchToProps
),
injectIntl
)(ListingPageComponent);
ListingPage.setInitialValues = initialValues => setInitialValues(initialValues);
ListingPage.loadData = loadData;

View file

@ -231,9 +231,13 @@ const mapDispatchToProps = dispatch => ({
onOpenListing: listingId => dispatch(openListing(listingId)),
});
const ManageListingsPage = compose(connect(mapStateToProps, mapDispatchToProps), injectIntl)(
ManageListingsPageComponent
);
const ManageListingsPage = compose(
connect(
mapStateToProps,
mapDispatchToProps
),
injectIntl
)(ManageListingsPageComponent);
ManageListingsPage.loadData = (params, search) => {
const queryParams = parse(search);

View file

@ -107,8 +107,10 @@ const mapStateToProps = state => {
// lifecycle hook.
//
// See: https://github.com/ReactTraining/react-router/issues/4671
const NotFoundPage = compose(withRouter, connect(mapStateToProps), injectIntl)(
NotFoundPageComponent
);
const NotFoundPage = compose(
withRouter,
connect(mapStateToProps),
injectIntl
)(NotFoundPageComponent);
export default NotFoundPage;

View file

@ -142,8 +142,12 @@ const mapDispatchToProps = dispatch => ({
onSubmitChangePassword: values => dispatch(changePassword(values)),
});
const PasswordChangePage = compose(connect(mapStateToProps, mapDispatchToProps), injectIntl)(
PasswordChangePageComponent
);
const PasswordChangePage = compose(
connect(
mapStateToProps,
mapDispatchToProps
),
injectIntl
)(PasswordChangePageComponent);
export default PasswordChangePage;

View file

@ -224,8 +224,12 @@ const mapDispatchToProps = dispatch => ({
onRetypeEmail: () => dispatch(retypePasswordRecoveryEmail()),
});
const PasswordRecoveryPage = compose(connect(mapStateToProps, mapDispatchToProps), injectIntl)(
PasswordRecoveryPageComponent
);
const PasswordRecoveryPage = compose(
connect(
mapStateToProps,
mapDispatchToProps
),
injectIntl
)(PasswordRecoveryPageComponent);
export default PasswordRecoveryPage;

View file

@ -180,7 +180,10 @@ const mapDispatchToProps = dispatch => ({
// See: https://github.com/ReactTraining/react-router/issues/4671
const PasswordResetPage = compose(
withRouter,
connect(mapStateToProps, mapDispatchToProps),
connect(
mapStateToProps,
mapDispatchToProps
),
injectIntl
)(PasswordResetPageComponent);

View file

@ -160,9 +160,13 @@ const mapDispatchToProps = dispatch => ({
onPayoutDetailsFormSubmit: values => dispatch(savePayoutDetails(values)),
});
const PayoutPreferencesPage = compose(connect(mapStateToProps, mapDispatchToProps), injectIntl)(
PayoutPreferencesPageComponent
);
const PayoutPreferencesPage = compose(
connect(
mapStateToProps,
mapDispatchToProps
),
injectIntl
)(PayoutPreferencesPageComponent);
PayoutPreferencesPage.loadData = loadData;

View file

@ -83,6 +83,9 @@ const mapStateToProps = state => {
};
};
const PrivacyPolicyPage = compose(connect(mapStateToProps), injectIntl)(PrivacyPolicyPageComponent);
const PrivacyPolicyPage = compose(
connect(mapStateToProps),
injectIntl
)(PrivacyPolicyPageComponent);
export default PrivacyPolicyPage;

View file

@ -313,9 +313,11 @@ const mapStateToProps = state => {
};
};
const ProfilePage = compose(connect(mapStateToProps), withViewport, injectIntl)(
ProfilePageComponent
);
const ProfilePage = compose(
connect(mapStateToProps),
withViewport,
injectIntl
)(ProfilePageComponent);
ProfilePage.loadData = params => {
const id = new UUID(params.id);

View file

@ -177,8 +177,12 @@ const mapDispatchToProps = dispatch => ({
onUpdateProfile: data => dispatch(updateProfile(data)),
});
const ProfileSettingsPage = compose(connect(mapStateToProps, mapDispatchToProps), injectIntl)(
ProfileSettingsPageComponent
);
const ProfileSettingsPage = compose(
connect(
mapStateToProps,
mapDispatchToProps
),
injectIntl
)(ProfileSettingsPageComponent);
export default ProfileSettingsPage;

View file

@ -332,9 +332,14 @@ const mapDispatchToProps = dispatch => ({
// lifecycle hook.
//
// See: https://github.com/ReactTraining/react-router/issues/4671
const SearchPage = compose(withRouter, connect(mapStateToProps, mapDispatchToProps), injectIntl)(
SearchPageComponent
);
const SearchPage = compose(
withRouter,
connect(
mapStateToProps,
mapDispatchToProps
),
injectIntl
)(SearchPageComponent);
SearchPage.loadData = (params, search) => {
const queryParams = parse(search, {

View file

@ -196,7 +196,9 @@ const StyleguidePage = props => {
const html =
examples.length > 0 ? (
<ul className={css.examplesList}>
{examples.map(ex => <Example key={`${ex.componentName}/${ex.exampleName}`} {...ex} />)}
{examples.map(ex => (
<Example key={`${ex.componentName}/${ex.exampleName}`} {...ex} />
))}
</ul>
) : (
<p>

View file

@ -83,8 +83,9 @@ const mapStateToProps = state => {
};
};
const TermsOfServicePage = compose(connect(mapStateToProps), injectIntl)(
TermsOfServicePageComponent
);
const TermsOfServicePage = compose(
connect(mapStateToProps),
injectIntl
)(TermsOfServicePageComponent);
export default TermsOfServicePage;

View file

@ -124,8 +124,12 @@ const mapDispatchToProps = dispatch => ({
// lifecycle hook.
//
// See: https://github.com/ReactTraining/react-router/issues/4671
const TopbarContainer = compose(withRouter, connect(mapStateToProps, mapDispatchToProps))(
TopbarContainerComponent
);
const TopbarContainer = compose(
withRouter,
connect(
mapStateToProps,
mapDispatchToProps
)
)(TopbarContainerComponent);
export default TopbarContainer;

View file

@ -282,9 +282,13 @@ const mapDispatchToProps = dispatch => {
};
};
const TransactionPage = compose(connect(mapStateToProps, mapDispatchToProps), injectIntl)(
TransactionPageComponent
);
const TransactionPage = compose(
connect(
mapStateToProps,
mapDispatchToProps
),
injectIntl
)(TransactionPageComponent);
TransactionPage.loadData = loadData;
TransactionPage.setInitialValues = setInitialValues;

View file

@ -64,8 +64,8 @@ const estimatedTransaction = (unitType, bookingStart, bookingEnd, unitPrice, qua
const unitCount = isNightly
? nightsBetween(bookingStart, bookingEnd)
: isDaily
? daysBetween(bookingStart, bookingEnd)
: quantity;
? daysBetween(bookingStart, bookingEnd)
: quantity;
const totalPrice = estimatedTotalPrice(unitPrice, unitCount);

View file

@ -141,8 +141,8 @@ export const withDimensions = (Component, options = {}) => {
clientWidth !== 0 && clientHeight !== 0
? { width: clientWidth, height: clientHeight }
: width !== 0 && height !== 0
? { width, height }
: {};
? { width, height }
: {};
const props = { ...this.props, dimensions: currentDimensions };

View file

@ -62,7 +62,7 @@ const obfuscatedCoordinatesImpl = (latlng, cacheKey) => {
lng + Math.atan2(sinBearing * sinTheta * cosLat, cosTheta - sinLat * Math.sin(newLat));
// Normalize -PI -> +PI radians
const newLngNormalized = (newLng + THREE_PI) % TWO_PI - Math.PI;
const newLngNormalized = ((newLng + THREE_PI) % TWO_PI) - Math.PI;
const result = radToDegrees({ lat: newLat, lng: newLngNormalized });
return new LatLng(result.lat, result.lng);
@ -129,26 +129,26 @@ export const circlePolyline = (latlng, radius) => {
const R = 6371;
const pi = Math.PI;
const _lat = lat * pi / 180;
const _lng = lng * pi / 180;
const _lat = (lat * pi) / 180;
const _lng = (lng * pi) / 180;
const d = radius / 1000 / R;
let points = [];
for (let i = 0; i <= 360; i += detail) {
const brng = i * pi / 180;
const brng = (i * pi) / 180;
let pLat = Math.asin(
Math.sin(_lat) * Math.cos(d) + Math.cos(_lat) * Math.sin(d) * Math.cos(brng)
);
const pLng =
(_lng +
((_lng +
Math.atan2(
Math.sin(brng) * Math.sin(d) * Math.cos(_lat),
Math.cos(d) - Math.sin(_lat) * Math.sin(pLat)
)) *
180 /
180) /
pi;
pLat = pLat * 180 / pi;
pLat = (pLat * 180) / pi;
points.push([pLat, pLng]);
}

View file

@ -6649,9 +6649,10 @@ preserve@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
prettier@^1.11.1:
version "1.12.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.12.1.tgz#c1ad20e803e7749faf905a409d2367e06bbe7325"
prettier@^1.15.3:
version "1.15.3"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.15.3.tgz#1feaac5bdd181237b54dbe65d874e02a1472786a"
integrity sha512-gAU9AGAPMaKb3NNSUUuhhFAS7SCO4ALTN4nRIn6PJ075Qd28Yn2Ig2ahEJWdJwJmlEBTUfC7mMUSFy8MwsOCfg==
pretty-bytes@^4.0.2:
version "4.0.2"