Skip to content

Commit 483a06d

Browse files
authored
Merge pull request #207 from react-native-community/chore/cleanup
Adjust repo codestyle
2 parents a2e1b65 + 7807f6f commit 483a06d

File tree

7 files changed

+5874
-344
lines changed

7 files changed

+5874
-344
lines changed

.eslintrc

Lines changed: 4 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -1,170 +1,8 @@
11
{
2+
"extends": "airbnb",
23
"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": 2, // 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
494

50-
/**
51-
* Possible errors
52-
*/
53-
"comma-dangle": [2, "always"], // http://eslint.org/docs/rules/comma-dangle
54-
"no-cond-assign": [2, "always"], // http://eslint.org/docs/rules/no-cond-assign
55-
"no-console": 1, // 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": 2, // 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": 2, // 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-extra-parens": 0, // 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-comment": 2 // http://eslint.org/docs/rules/spaced-line-comment
5+
"rules": {
6+
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }]
1697
}
170-
}
8+
}

NavbarButton.js

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { Component, PropTypes } from 'react';
1+
import React, { PropTypes } from 'react';
22
import {
33
Text,
44
TouchableOpacity,
@@ -7,34 +7,37 @@ import {
77

88
import styles from './styles';
99

10-
export default class NavbarButton extends Component {
11-
render() {
12-
const { style, tintColor, margin, title, handler, disabled } = this.props;
10+
export default function NavbarButton(props) {
11+
const { style, tintColor, title, handler, disabled } = props;
1312

14-
return (
15-
<TouchableOpacity style={styles.navBarButton} onPress={handler} disabled={disabled}>
16-
<View style={style}>
17-
<Text style={[styles.navBarButtonText, { color: tintColor, }, ]}>{title}</Text>
18-
</View>
19-
</TouchableOpacity>
20-
);
21-
}
13+
return (
14+
<TouchableOpacity
15+
style={styles.navBarButton}
16+
onPress={handler}
17+
disabled={disabled}
18+
>
19+
<View style={style}>
20+
<Text style={[styles.navBarButtonText, { color: tintColor }]}>{title}</Text>
21+
</View>
22+
</TouchableOpacity>
23+
);
24+
}
2225

23-
static propTypes = {
24-
style: PropTypes.oneOfType([
25-
PropTypes.object,
26-
PropTypes.array,
27-
]),
28-
tintColor: PropTypes.string,
29-
title: PropTypes.string,
30-
handler: PropTypes.func,
31-
disabled: PropTypes.bool,
32-
};
26+
NavbarButton.propTypes = {
27+
style: PropTypes.oneOfType([
28+
PropTypes.object,
29+
PropTypes.array,
30+
]),
31+
tintColor: PropTypes.string,
32+
title: PropTypes.string,
33+
handler: PropTypes.func,
34+
disabled: PropTypes.bool,
35+
};
3336

34-
static defaultProps = {
35-
style: {},
36-
title: '',
37-
tintColor: '#0076FF',
38-
onPress: () => ({}),
39-
};
40-
}
37+
NavbarButton.defaultProps = {
38+
style: {},
39+
title: '',
40+
tintColor: '#0076FF',
41+
disabled: false,
42+
handler: () => ({}),
43+
};

README.md

Lines changed: 37 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -9,70 +9,51 @@
99
- [Usage with webpack](#usage-with-webpack)
1010
- [Questions?](#questions)
1111

12-
### Installation
13-
First of all, make sure you're using `npm3+` and `babel6` for version `1.1.1` or above.
14-
15-
```bash
16-
npm i react-native-navbar --save
17-
```
18-
1912
### Examples
2013
- [Basic](https://github.com/Kureev/react-native-navbar/tree/master/examples/Basic)
2114
- [Custom Elements](https://github.com/Kureev/react-native-navbar/tree/master/examples/CustomElements)
2215
- [Routing](https://github.com/Kureev/react-native-navbar/tree/master/examples/Routing)
2316

2417
### Getting started
25-
*First of all, I assume you've already made a react-native project by running `react-native init project-name` and installed `react-native-navbar` component by `npm`.*
26-
27-
In your `index.ios.js` file require `react-native-navbar` component:
28-
```jsx
29-
var NavigationBar = require('react-native-navbar');
30-
```
31-
or, if you use ES2015 syntax:
32-
```jsx
33-
import NavigationBar from 'react-native-navbar';
34-
```
35-
36-
Inside your component's `render` method, use `NavigationBar`:
37-
```jsx
38-
render: function() {
39-
var rightButtonConfig = {
40-
title: 'Next',
41-
handler: function onNext() {
42-
alert('hello!');
43-
}
44-
};
45-
46-
var titleConfig = {
47-
title: 'Hello, world',
48-
};
49-
50-
return (
51-
<View style={{ flex: 1, }}>
52-
<NavigationBar
53-
title={titleConfig}
54-
rightButton={rightButtonConfig} />
55-
</View>
56-
);
57-
}
58-
```
59-
or, if you use ES2015:
18+
- Install `react-native-navbar`:
19+
- By using `yarn`:
20+
```
21+
$ yarn add react-native-navbar
22+
```
23+
- By using `npm`:
24+
```
25+
$ npm install react-native-navbar --save
26+
```
27+
28+
- Import it in the file where you want to use it:
29+
```jsx
30+
import NavigationBar from 'react-native-navbar';
31+
```
32+
33+
- Add it to your React element tree:
6034
```jsx
61-
render() {
62-
const rightButtonConfig = {
63-
title: 'Next',
64-
handler: () => alert('hello!'),
65-
};
66-
67-
const titleConfig = {
68-
title: 'Hello, world',
69-
};
70-
35+
const styles = {
36+
container: {
37+
flex: 1,
38+
},
39+
};
40+
41+
const rightButtonConfig = {
42+
title: 'Next',
43+
handler: () => alert('hello!'),
44+
};
45+
46+
const titleConfig = {
47+
title: 'Hello, world',
48+
};
49+
50+
function ComponentWithNavigationBar() {
7151
return (
72-
<View style={{ flex: 1, }}>
52+
<View style={styles.container}>
7353
<NavigationBar
7454
title={titleConfig}
75-
rightButton={rightButtonConfig} />
55+
rightButton={rightButtonConfig}
56+
/>
7657
</View>
7758
);
7859
}
@@ -118,8 +99,5 @@ loaders: [{
11899
```
119100

120101
### Questions?
121-
Feel free to contact me via
122-
- [Twitter](https://twitter.com/kureevalexey)
123-
- Slack (@kureev on #reactiflux channel)
124-
125-
If you want to report a bug, please [submit an issue!](https://github.com/Kureev/react-native-navbar/issues/new)
102+
Feel free to ping me on [twitter](https://twitter.com/kureevalexey)
103+
If you want to report a bug, please [submit an issue!](https://github.com/react-native-community/react-native-navbar/issues/new)

0 commit comments

Comments
 (0)