Skip to content

Commit 19f7484

Browse files
authored
Ensure examples are clear: always use explicit arrow parens (#82)
1 parent 36ac1fb commit 19f7484

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+86
-84
lines changed

.prettierrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
{
1010
"files": ["website/core/**/*.js", "website/static/js/**/*.js"],
1111
"options": {
12+
"arrowParens": "avoid",
1213
"bracketSpacing": false,
1314
"jsxBracketSameLine": true,
1415
"printWidth": 80,
@@ -23,6 +24,7 @@
2324
"website/blog/**/*.md"
2425
],
2526
"options": {
27+
"arrowParens": "always",
2628
"bracketSpacing": false,
2729
"jsxBracketSameLine": true,
2830
"printWidth": 80,

docs/accessibilityinfo.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ScreenReaderStatusExample extends React.Component {
1818
'change',
1919
this._handleScreenReaderToggled
2020
);
21-
AccessibilityInfo.fetch().done(isEnabled => {
21+
AccessibilityInfo.fetch().done((isEnabled) => {
2222
this.setState({
2323
screenReaderEnabled: isEnabled,
2424
});
@@ -32,7 +32,7 @@ class ScreenReaderStatusExample extends React.Component {
3232
);
3333
}
3434

35-
_handleScreenReaderToggled = isEnabled => {
35+
_handleScreenReaderToggled = (isEnabled) => {
3636
this.setState({
3737
screenReaderEnabled: isEnabled,
3838
});

docs/alertios.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ AlertIOS.prompt(
115115
},
116116
{
117117
text: 'OK',
118-
onPress: password => console.log('OK Pressed, password: ' + password),
118+
onPress: (password) => console.log('OK Pressed, password: ' + password),
119119
},
120120
],
121121
'secure-text'
@@ -130,7 +130,7 @@ Example with the default button and a custom callback:
130130
AlertIOS.prompt(
131131
'Update username',
132132
null,
133-
text => console.log('Your username is ' + text),
133+
(text) => console.log('Your username is ' + text),
134134
null,
135135
'default'
136136
);

docs/asyncstorage.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ Example:
275275
276276
```javascript
277277
let keys = ['k1', 'k2'];
278-
AsyncStorage.multiRemove(keys, err => {
278+
AsyncStorage.multiRemove(keys, (err) => {
279279
// keys k1 & k2 removed, if they existed
280280
// do most stuff after removal (if you want)
281281
});
@@ -338,8 +338,8 @@ let multi_merge_pairs = [
338338
['UID345', JSON.stringify(UID345_delta)],
339339
];
340340

341-
AsyncStorage.multiSet(multi_set_pairs, err => {
342-
AsyncStorage.multiMerge(multi_merge_pairs, err => {
341+
AsyncStorage.multiSet(multi_set_pairs, (err) => {
342+
AsyncStorage.multiMerge(multi_merge_pairs, (err) => {
343343
AsyncStorage.multiGet(['UID234', 'UID345'], (err, stores) => {
344344
stores.map((result, i, store) => {
345345
let key = store[i][0];

docs/custom-webview-android.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ export default class CustomWebView extends Component {
217217
finalUrl: 'about:blank',
218218
};
219219

220-
_onNavigationCompleted = event => {
220+
_onNavigationCompleted = (event) => {
221221
const {onNavigationCompleted} = this.props;
222222
onNavigationCompleted && onNavigationCompleted(event);
223223
};

docs/custom-webview-ios.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export default class CustomWebView extends Component {
190190
finalUrl: 'about:blank',
191191
};
192192

193-
_onNavigationCompleted = event => {
193+
_onNavigationCompleted = (event) => {
194194
const {onNavigationCompleted} = this.props;
195195
onNavigationCompleted && onNavigationCompleted(event);
196196
};

docs/headless-js-android.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ AppRegistry.registerHeadlessTask('SomeTaskName', () => require('SomeTaskName'));
1616
Then, in `SomeTaskName.js`:
1717

1818
```javascript
19-
module.exports = async taskData => {
19+
module.exports = async (taskData) => {
2020
// do stuff
2121
};
2222
```

docs/integration-with-existing-apps.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ import {AppRegistry, StyleSheet, Text, View} from 'react-native';
314314

315315
class RNHighScores extends React.Component {
316316
render() {
317-
var contents = this.props['scores'].map(score => (
317+
var contents = this.props['scores'].map((score) => (
318318
<Text key={score.name}>
319319
{score.name}:{score.value}
320320
{'\n'}

docs/native-modules-android.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ This method would be accessed in JavaScript using:
198198
UIManager.measureLayout(
199199
100,
200200
100,
201-
msg => {
201+
(msg) => {
202202
console.log(msg);
203203
},
204204
(x, y, width, height) => {

docs/network.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ Networking is an inherently asynchronous operation. Fetch methods will return a
4444
```javascript
4545
function getMoviesFromApiAsync() {
4646
return fetch('https://facebook.github.io/react-native/movies.json')
47-
.then(response => response.json())
48-
.then(responseJson => {
47+
.then((response) => response.json())
48+
.then((responseJson) => {
4949
return responseJson.movies;
5050
})
51-
.catch(error => {
51+
.catch((error) => {
5252
console.error(error);
5353
});
5454
}
@@ -130,7 +130,7 @@ The [XMLHttpRequest API](https://developer.mozilla.org/en-US/docs/Web/API/XMLHtt
130130

131131
```javascript
132132
var request = new XMLHttpRequest();
133-
request.onreadystatechange = e => {
133+
request.onreadystatechange = (e) => {
134134
if (request.readyState !== 4) {
135135
return;
136136
}
@@ -160,17 +160,17 @@ ws.onopen = () => {
160160
ws.send('something'); // send a message
161161
};
162162

163-
ws.onmessage = e => {
163+
ws.onmessage = (e) => {
164164
// a message was received
165165
console.log(e.data);
166166
};
167167

168-
ws.onerror = e => {
168+
ws.onerror = (e) => {
169169
// an error occurred
170170
console.log(e.message);
171171
};
172172

173-
ws.onclose = e => {
173+
ws.onclose = (e) => {
174174
// connection closed
175175
console.log(e.code, e.reason);
176176
};

0 commit comments

Comments
 (0)