From 6897dbcaa5029d9a2c813409b03feb206485a946 Mon Sep 17 00:00:00 2001 From: Vojtech Novak Date: Thu, 9 Apr 2020 10:32:59 +0200 Subject: [PATCH 1/2] enable prettier by default --- .prettierrc | 4 +- example/App.js | 84 ++++++++++++++++++++++------------------- example/index.js | 4 -- package.json | 2 +- src/BlurView.android.js | 17 ++++----- src/BlurView.ios.js | 15 +++++--- src/VibrancyView.ios.js | 6 +-- 7 files changed, 69 insertions(+), 63 deletions(-) diff --git a/.prettierrc b/.prettierrc index 832069c..4af0646 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,8 +1,6 @@ { - "requirePragma": true, "singleQuote": true, "trailingComma": "all", "bracketSpacing": false, - "jsxBracketSameLine": true, - "parser": "flow" + "jsxBracketSameLine": true } diff --git a/example/App.js b/example/App.js index a22e88b..70e9830 100644 --- a/example/App.js +++ b/example/App.js @@ -2,7 +2,7 @@ * Basic [iOS] Example for react-native-blur * https://github.com/react-native-community/react-native-blur */ -import React, { Component } from 'react'; +import React, {Component} from 'react'; import { Image, SegmentedControlIOS, @@ -13,7 +13,7 @@ import { View, } from 'react-native'; -import { BlurView, VibrancyView } from '@react-native-community/blur'; +import {BlurView, VibrancyView} from '@react-native-community/blur'; export default class Basic extends Component { constructor(props) { @@ -37,7 +37,9 @@ export default class Basic extends Component { } _onVibrancyChange(event) { - this.setState({vibrancyActiveSegment: event.nativeEvent.selectedSegmentIndex}); + this.setState({ + vibrancyActiveSegment: event.nativeEvent.selectedSegmentIndex, + }); } _onVibrancyValueChange(value) { @@ -62,17 +64,22 @@ export default class Basic extends Component { blurAmount={100} reducedTransparencyFallbackColor={'pink'} style={[styles.blurView]}> - + Blur component ({platform}) - {Platform.OS === 'ios' && - {this._onBlurChange(event);}} - onValueChange={(value) => {this._onBlurValueChange(value);}} - tintColor={tintColor} - />} + {Platform.OS === 'ios' && ( + { + this._onBlurChange(event); + }} + onValueChange={(value) => { + this._onBlurValueChange(value); + }} + tintColor={tintColor} + /> + )} @@ -81,25 +88,27 @@ export default class Basic extends Component { VibrancyView is only supported on iOS, and must contain child views, otherwise the vibrancy effect doesn't work. */ - Platform.OS === 'ios' && - + Platform.OS === 'ios' && ( + + Vibrancy component (iOS-only) - - Vibrancy component (iOS-only) - - - {this._onVibrancyChange(event);}} - onValueChange={(value) => {this._onVibrancyValueChange(value);}} - tintColor="white" - /> - + { + this._onVibrancyChange(event); + }} + onValueChange={(value) => { + this._onVibrancyValueChange(value); + }} + tintColor="white" + /> + + ) } ); @@ -107,22 +116,21 @@ export default class Basic extends Component { render() { return ( - + + style={styles.img} + /> - { this.state.showBlurs ? this.renderBlurs() : null } + {this.state.showBlurs ? this.renderBlurs() : null} - + this.setState({showBlurs: value})} - value={this.state.showBlurs} /> + value={this.state.showBlurs} + /> - ); } diff --git a/example/index.js b/example/index.js index a850d03..7cd584c 100644 --- a/example/index.js +++ b/example/index.js @@ -1,7 +1,3 @@ -/** - * @format - */ - import {AppRegistry} from 'react-native'; import App from './App'; import {name as appName} from './app.json'; diff --git a/package.json b/package.json index 2c8bcef..0ba69c8 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "lint": "eslint src index.js" + "lint": "eslint src index.js example" }, "repository": { "type": "git", diff --git a/src/BlurView.android.js b/src/BlurView.android.js index a192476..119c2bc 100644 --- a/src/BlurView.android.js +++ b/src/BlurView.android.js @@ -1,4 +1,4 @@ -import React, { Component } from 'react'; +import React, {Component} from 'react'; import PropTypes from 'prop-types'; import { View, @@ -16,7 +16,7 @@ const OVERLAY_COLORS = { class BlurView extends Component { componentDidMount() { - DeviceEventEmitter.addListener('ReactNativeBlurError', message => { + DeviceEventEmitter.addListener('ReactNativeBlurError', (message) => { throw new Error(`[ReactNativeBlur]: ${message}`); }); } @@ -33,12 +33,12 @@ class BlurView extends Component { } blurRadius() { - const { blurRadius, blurAmount } = this.props; + const {blurRadius, blurAmount} = this.props; if (blurRadius != null) { if (blurRadius > 25) { throw new Error( - `[ReactNativeBlur]: blurRadius cannot be greater than 25! (was: ${blurRadius})` + `[ReactNativeBlur]: blurRadius cannot be greater than 25! (was: ${blurRadius})`, ); } return blurRadius; @@ -55,7 +55,7 @@ class BlurView extends Component { } downsampleFactor() { - const { downsampleFactor, blurRadius } = this.props; + const {downsampleFactor, blurRadius} = this.props; if (downsampleFactor != null) { return downsampleFactor; } @@ -63,7 +63,7 @@ class BlurView extends Component { } render() { - const { style } = this.props; + const {style} = this.props; return ( + style={StyleSheet.compose(styles.transparent, style)}> {this.props.children} ); @@ -80,7 +79,7 @@ class BlurView extends Component { } const styles = StyleSheet.create({ - transparent: { backgroundColor: 'transparent' }, + transparent: {backgroundColor: 'transparent'}, }); BlurView.propTypes = { diff --git a/src/BlurView.ios.js b/src/BlurView.ios.js index f675bf9..1b9c819 100644 --- a/src/BlurView.ios.js +++ b/src/BlurView.ios.js @@ -1,9 +1,14 @@ -import React, { Component } from 'react'; +import React, {Component} from 'react'; import PropTypes from 'prop-types'; -import {View, requireNativeComponent, ViewPropTypes, StyleSheet} from 'react-native'; +import { + View, + requireNativeComponent, + ViewPropTypes, + StyleSheet, +} from 'react-native'; class BlurView extends Component { - setNativeProps = nativeProps => { + setNativeProps = (nativeProps) => { if (this._root) { this._root.setNativeProps(nativeProps); } @@ -12,7 +17,7 @@ class BlurView extends Component { render() { return ( (this._root = e)} + ref={(e) => (this._root = e)} {...this.props} style={StyleSheet.compose(styles.transparent, this.props.style)} /> @@ -21,7 +26,7 @@ class BlurView extends Component { } const styles = StyleSheet.create({ - transparent: { backgroundColor: 'transparent' }, + transparent: {backgroundColor: 'transparent'}, }); BlurView.propTypes = { diff --git a/src/VibrancyView.ios.js b/src/VibrancyView.ios.js index afd5760..30d994a 100644 --- a/src/VibrancyView.ios.js +++ b/src/VibrancyView.ios.js @@ -1,9 +1,9 @@ -import React, { Component } from 'react'; +import React, {Component} from 'react'; import PropTypes from 'prop-types'; import {requireNativeComponent, StyleSheet} from 'react-native'; class VibrancyView extends Component { - setNativeProps = nativeProps => { + setNativeProps = (nativeProps) => { if (this._root) { this._root.setNativeProps(nativeProps); } @@ -20,7 +20,7 @@ class VibrancyView extends Component { } const styles = StyleSheet.create({ - transparent: { backgroundColor: 'transparent' }, + transparent: {backgroundColor: 'transparent'}, }); VibrancyView.propTypes = { From c228a9741340442e79bff2003e271626b0c8ae08 Mon Sep 17 00:00:00 2001 From: Vojtech Novak Date: Thu, 9 Apr 2020 10:33:21 +0200 Subject: [PATCH 2/2] remove add --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 0ba69c8..53c9846 100644 --- a/package.json +++ b/package.json @@ -42,8 +42,7 @@ }, "lint-staged": { "*.{js,json,css,md}": [ - "prettier --write", - "git add" + "prettier --write" ] } }