Skip to content

Commit c0b9a6e

Browse files
authored
Configure Eslint & Prettier (#302)
1 parent 6bdcefe commit c0b9a6e

16 files changed

+2629
-279
lines changed

.eslintrc

Lines changed: 1 addition & 168 deletions
Original file line numberDiff line numberDiff line change
@@ -1,170 +1,3 @@
11
{
2-
"parser": "babel-eslint",
3-
"env": {
4-
"browser": true,
5-
"node": true,
6-
"jasmine": true
7-
},
8-
"ecmaFeatures": {
9-
"arrowFunctions": true,
10-
"blockBindings": true,
11-
"classes": true,
12-
"defaultParams": true,
13-
"destructuring": true,
14-
"forOf": true,
15-
"generators": false,
16-
"modules": true,
17-
"objectLiteralComputedProperties": true,
18-
"objectLiteralDuplicateProperties": false,
19-
"objectLiteralShorthandMethods": true,
20-
"objectLiteralShorthandProperties": true,
21-
"spread": true,
22-
"superInFunctions": true,
23-
"templateStrings": true,
24-
"jsx": true
25-
},
26-
"rules": {
27-
/**
28-
* Strict mode
29-
*/
30-
// babel inserts "use strict"; for us
31-
// http://eslint.org/docs/rules/strict
32-
"strict": [2, "never"],
33-
34-
/**
35-
* ES6
36-
*/
37-
"no-var": 0, // http://eslint.org/docs/rules/no-var
38-
39-
/**
40-
* Variables
41-
*/
42-
"no-shadow": 2, // http://eslint.org/docs/rules/no-shadow
43-
"no-shadow-restricted-names": 2, // http://eslint.org/docs/rules/no-shadow-restricted-names
44-
"no-unused-vars": [0, { // http://eslint.org/docs/rules/no-unused-vars
45-
"vars": "local",
46-
"args": "after-used"
47-
}],
48-
"no-use-before-define": 2, // http://eslint.org/docs/rules/no-use-before-define
49-
50-
/**
51-
* Possible errors
52-
*/
53-
"comma-dangle": [2, "always-multiline"], // http://eslint.org/docs/rules/comma-dangle
54-
"no-cond-assign": [2, "always"], // http://eslint.org/docs/rules/no-cond-assign
55-
"no-console": 0, // http://eslint.org/docs/rules/no-console
56-
"no-debugger": 1, // http://eslint.org/docs/rules/no-debugger
57-
"no-alert": 1, // http://eslint.org/docs/rules/no-alert
58-
"no-constant-condition": 1, // http://eslint.org/docs/rules/no-constant-condition
59-
"no-dupe-keys": 2, // http://eslint.org/docs/rules/no-dupe-keys
60-
"no-duplicate-case": 2, // http://eslint.org/docs/rules/no-duplicate-case
61-
"no-empty": 2, // http://eslint.org/docs/rules/no-empty
62-
"no-ex-assign": 2, // http://eslint.org/docs/rules/no-ex-assign
63-
"no-extra-boolean-cast": 0, // http://eslint.org/docs/rules/no-extra-boolean-cast
64-
"no-extra-semi": 2, // http://eslint.org/docs/rules/no-extra-semi
65-
"no-func-assign": 2, // http://eslint.org/docs/rules/no-func-assign
66-
"no-inner-declarations": 2, // http://eslint.org/docs/rules/no-inner-declarations
67-
"no-invalid-regexp": 2, // http://eslint.org/docs/rules/no-invalid-regexp
68-
"no-irregular-whitespace": 2, // http://eslint.org/docs/rules/no-irregular-whitespace
69-
"no-obj-calls": 2, // http://eslint.org/docs/rules/no-obj-calls
70-
"no-reserved-keys": 0, // http://eslint.org/docs/rules/no-reserved-keys
71-
"no-sparse-arrays": 2, // http://eslint.org/docs/rules/no-sparse-arrays
72-
"no-unreachable": 2, // http://eslint.org/docs/rules/no-unreachable
73-
"use-isnan": 2, // http://eslint.org/docs/rules/use-isnan
74-
"block-scoped-var": 2, // http://eslint.org/docs/rules/block-scoped-var
75-
76-
/**
77-
* Best practices
78-
*/
79-
"consistent-return": 2, // http://eslint.org/docs/rules/consistent-return
80-
"curly": [2, "multi-line"], // http://eslint.org/docs/rules/curly
81-
"default-case": 2, // http://eslint.org/docs/rules/default-case
82-
"dot-notation": [2, { // http://eslint.org/docs/rules/dot-notation
83-
"allowKeywords": true
84-
}],
85-
"eqeqeq": ["error", "smart"], // http://eslint.org/docs/rules/eqeqeq
86-
"guard-for-in": 2, // http://eslint.org/docs/rules/guard-for-in
87-
"no-caller": 2, // http://eslint.org/docs/rules/no-caller
88-
"no-else-return": 2, // http://eslint.org/docs/rules/no-else-return
89-
"no-eq-null": 0, // http://eslint.org/docs/rules/no-eq-null
90-
"no-eval": 2, // http://eslint.org/docs/rules/no-eval
91-
"no-extend-native": 2, // http://eslint.org/docs/rules/no-extend-native
92-
"no-extra-bind": 2, // http://eslint.org/docs/rules/no-extra-bind
93-
"no-fallthrough": 2, // http://eslint.org/docs/rules/no-fallthrough
94-
"no-floating-decimal": 2, // http://eslint.org/docs/rules/no-floating-decimal
95-
"no-implied-eval": 2, // http://eslint.org/docs/rules/no-implied-eval
96-
"no-lone-blocks": 2, // http://eslint.org/docs/rules/no-lone-blocks
97-
"no-loop-func": 2, // http://eslint.org/docs/rules/no-loop-func
98-
"no-multi-str": 2, // http://eslint.org/docs/rules/no-multi-str
99-
"no-native-reassign": 2, // http://eslint.org/docs/rules/no-native-reassign
100-
"no-new": 2, // http://eslint.org/docs/rules/no-new
101-
"no-new-func": 2, // http://eslint.org/docs/rules/no-new-func
102-
"no-new-wrappers": 2, // http://eslint.org/docs/rules/no-new-wrappers
103-
"no-octal": 2, // http://eslint.org/docs/rules/no-octal
104-
"no-octal-escape": 2, // http://eslint.org/docs/rules/no-octal-escape
105-
"no-param-reassign": 2, // http://eslint.org/docs/rules/no-param-reassign
106-
"no-proto": 2, // http://eslint.org/docs/rules/no-proto
107-
"no-redeclare": 2, // http://eslint.org/docs/rules/no-redeclare
108-
"no-return-assign": 2, // http://eslint.org/docs/rules/no-return-assign
109-
"no-script-url": 2, // http://eslint.org/docs/rules/no-script-url
110-
"no-self-compare": 2, // http://eslint.org/docs/rules/no-self-compare
111-
"no-sequences": 2, // http://eslint.org/docs/rules/no-sequences
112-
"no-throw-literal": 2, // http://eslint.org/docs/rules/no-throw-literal
113-
"no-with": 2, // http://eslint.org/docs/rules/no-with
114-
"radix": 2, // http://eslint.org/docs/rules/radix
115-
"vars-on-top": 2, // http://eslint.org/docs/rules/vars-on-top
116-
"wrap-iife": [2, "any"], // http://eslint.org/docs/rules/wrap-iife
117-
"yoda": 2, // http://eslint.org/docs/rules/yoda
118-
119-
/**
120-
* Style
121-
*/
122-
"indent": [2, 2], // http://eslint.org/docs/rules/
123-
"brace-style": [2, // http://eslint.org/docs/rules/brace-style
124-
"1tbs", {
125-
"allowSingleLine": true
126-
}],
127-
"quotes": [
128-
2, "single", "avoid-escape" // http://eslint.org/docs/rules/quotes
129-
],
130-
"camelcase": [2, { // http://eslint.org/docs/rules/camelcase
131-
"properties": "never"
132-
}],
133-
"comma-spacing": [2, { // http://eslint.org/docs/rules/comma-spacing
134-
"before": false,
135-
"after": true
136-
}],
137-
"comma-style": [2, "last"], // http://eslint.org/docs/rules/comma-style
138-
"eol-last": 2, // http://eslint.org/docs/rules/eol-last
139-
"func-names": 1, // http://eslint.org/docs/rules/func-names
140-
"key-spacing": [2, { // http://eslint.org/docs/rules/key-spacing
141-
"beforeColon": false,
142-
"afterColon": true
143-
}],
144-
"new-cap": [2, { // http://eslint.org/docs/rules/new-cap
145-
"newIsCap": true
146-
}],
147-
"no-multiple-empty-lines": [2, { // http://eslint.org/docs/rules/no-multiple-empty-lines
148-
"max": 2
149-
}],
150-
"no-nested-ternary": 2, // http://eslint.org/docs/rules/no-nested-ternary
151-
"no-new-object": 2, // http://eslint.org/docs/rules/no-new-object
152-
"no-spaced-func": 2, // http://eslint.org/docs/rules/no-spaced-func
153-
"no-trailing-spaces": 2, // http://eslint.org/docs/rules/no-trailing-spaces
154-
"no-wrap-func": 2, // http://eslint.org/docs/rules/no-wrap-func
155-
"no-underscore-dangle": 0, // http://eslint.org/docs/rules/no-underscore-dangle
156-
"one-var": [2, "never"], // http://eslint.org/docs/rules/one-var
157-
"padded-blocks": 0, // http://eslint.org/docs/rules/padded-blocks
158-
"semi": [2, "always"], // http://eslint.org/docs/rules/semi
159-
"semi-spacing": [2, { // http://eslint.org/docs/rules/semi-spacing
160-
"before": false,
161-
"after": true
162-
}],
163-
"space-after-keywords": 2, // http://eslint.org/docs/rules/space-after-keywords
164-
"space-before-blocks": 2, // http://eslint.org/docs/rules/space-before-blocks
165-
"space-before-function-paren": [2, "never"], // http://eslint.org/docs/rules/space-before-function-paren
166-
"space-infix-ops": 2, // http://eslint.org/docs/rules/space-infix-ops
167-
"space-return-throw-case": 2, // http://eslint.org/docs/rules/space-return-throw-case
168-
"spaced-line-comment": 2 // http://eslint.org/docs/rules/spaced-line-comment
169-
}
2+
"extends": "@react-native-community"
1703
}

.prettierrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"requirePragma": true,
3+
"singleQuote": true,
4+
"trailingComma": "all",
5+
"bracketSpacing": false,
6+
"jsxBracketSameLine": true,
7+
"parser": "flow"
8+
}

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"eslint.autoFixOnSave": true,
3+
"editor.formatOnSave": true
4+
}

README.md

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ A component for UIVisualEffectView's blur and vibrancy effect on iOS, and [500px
66

77
<img src='https://cloud.githubusercontent.com/assets/139536/25066337/3c9d44c0-224d-11e7-8ca6-028478bf4a7d.gif' />
88

9-
109
### Content
1110

1211
- [Installation](#installation)
@@ -15,21 +14,21 @@ A component for UIVisualEffectView's blur and vibrancy effect on iOS, and [500px
1514
- [Example React Native app](#example-react-native-app)
1615
- [Questions?](#questions)
1716

18-
1917
### Installation
2018

2119
**NOTE:** Latest version of the package is available in npm as `[email protected]`
2220

2321
1. Install package via npm:
2422

25-
```
26-
npm install react-native-blur
27-
```
23+
```
24+
npm install react-native-blur
25+
```
2826

2927
2. Link your native dependencies:
30-
```
31-
react-native link react-native-blur
32-
```
28+
29+
```
30+
react-native link react-native-blur
31+
```
3332

3433
3. (Android only) Add the following to `android/app/build.gradle`
3534

@@ -49,17 +48,16 @@ android {
4948

5049
4. Include the library in your code:
5150

52-
```javascript
53-
import { BlurView, VibrancyView } from 'react-native-blur';
51+
```javascript
52+
import { BlurView, VibrancyView } from "react-native-blur";
5453

55-
// OR
54+
// OR
5655

57-
const { BlurView, VibrancyView } = require('react-native-blur');
58-
```
56+
const { BlurView, VibrancyView } = require("react-native-blur");
57+
```
5958

6059
5. Compile and have fun!
6160

62-
6361
### BlurView
6462

6563
**Properties:**
@@ -79,9 +77,9 @@ android {
7977
> Complete usage example that works on iOS and Android:
8078
8179
```javascript
82-
import React, { Component } from 'react';
83-
import { View, Image, Text, findNodeHandle, StyleSheet } from 'react-native';
84-
import { BlurView } from 'react-native-blur';
80+
import React, { Component } from "react";
81+
import { View, Image, Text, findNodeHandle, StyleSheet } from "react-native";
82+
import { BlurView } from "react-native-blur";
8583

8684
export default class Menu extends Component {
8785
constructor(props) {
@@ -104,8 +102,10 @@ export default class Menu extends Component {
104102
blurAmount={10}
105103
/>
106104
<Image
107-
ref={(img) => { this.backgroundImage = img; }}
108-
source={{uri}}
105+
ref={img => {
106+
this.backgroundImage = img;
107+
}}
108+
source={{ uri }}
109109
style={styles.absolute}
110110
onLoadEnd={this.imageLoaded.bind(this)}
111111
/>
@@ -116,13 +116,16 @@ export default class Menu extends Component {
116116

117117
const styles = StyleSheet.create({
118118
container: {
119-
justifyContent: 'center',
120-
alignItems: 'center',
119+
justifyContent: "center",
120+
alignItems: "center"
121121
},
122122
absolute: {
123123
position: "absolute",
124-
top: 0, left: 0, bottom: 0, right: 0,
125-
},
124+
top: 0,
125+
left: 0,
126+
bottom: 0,
127+
right: 0
128+
}
126129
});
127130
```
128131

@@ -139,12 +142,12 @@ Note that `viewRef` is only required if you need to support Android. See the [An
139142
> (Note: `VibrancyView` is only supported on iOS. Also note that the `VibrancyView` must contain nested views.)
140143
141144
```javascript
142-
import { VibrancyView } from 'react-native-blur';
145+
import { VibrancyView } from "react-native-blur";
143146

144147
export default class Menu extends Component {
145148
render() {
146149
return (
147-
<Image source={{uri}} style={styles.absolute}>
150+
<Image source={{ uri }} style={styles.absolute}>
148151
<VibrancyView blurType="light" style={styles.flex}>
149152
<Text>Hi, I am some vibrant text.</Text>
150153
</VibrancyView>
@@ -160,17 +163,16 @@ Android uses the [500px-android-blur](https://github.com/500px/500px-android-blu
160163

161164
The Android library introduces some limitations:
162165

163-
* `BlurView` cannot be a child of the view that is being blurred (this would cause an infinite loop)
164-
* `BlurView` cannot contain any child components.
166+
- `BlurView` cannot be a child of the view that is being blurred (this would cause an infinite loop)
167+
- `BlurView` cannot contain any child components.
165168

166169
If you only need to support iOS, then you can safely ignore these limitations.
167170

168171
In addition to `blurType` and `blurAmount`, Android has some extra props that can be used to override the default behavior (or configure Android-specific behavior):
169172

170-
- `blurRadius` (Number - between 0 and 25) - Manually adjust the blur radius. (Default: matches iOS blurAmount)
173+
- `blurRadius` (Number - between 0 and 25) - Manually adjust the blur radius. (Default: matches iOS blurAmount)
171174
- `downsampleFactor` (Number - between 0 and 25) - Scales down the image before blurring (Default: matches iOS blurAmount)
172-
- `overlayColor` (Color) - Set a custom overlay color (Default color based on iOS blurType)
173-
175+
- `overlayColor` (Color) - Set a custom overlay color (Default color based on iOS blurType)
174176

175177
### Example React Native App
176178

@@ -207,6 +209,7 @@ react-native run-ios
207209
#### Run the tvOS app
208210

209211
type:
212+
210213
```
211214
react-native run-ios
212215
```
@@ -237,12 +240,12 @@ That’s all, you can use react-native-blur for your tvOS application
237240
react-native run-android
238241
```
239242

240-
241243
### Troubleshooting
242244

243245
On older instances of react-native, BlurView package does not get added into the MainActivity/MainApplication classes where you would see `Warning: Native component for 'BlurView' does not exist` in RN YellowBox or console.
244246

245247
To rectify this, you can add the BlurViewPackage manually in MainActivity/MainApplication classes
248+
246249
```java
247250
...
248251
import com.cmcewen.blurview.BlurViewPackage;
@@ -261,7 +264,6 @@ public class MainApplication extends Application implements ReactApplication {
261264
}
262265
```
263266

264-
265267
### Questions?
266268

267269
Feel free to contact me in [twitter](https://twitter.com/kureevalexey) or [create an issue](https://github.com/Kureev/react-native-blur/issues/new)

examples/Basic/__tests__/index.android.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

examples/Basic/__tests__/index.ios.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)