Skip to content

Commit d812ca3

Browse files
author
Krzysztof Borowy
committed
feat: add lint and type tests
1 parent 0e5d775 commit d812ca3

File tree

6 files changed

+16
-21
lines changed

6 files changed

+16
-21
lines changed

.eslintrc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
"env": {
77
"es6": true,
8+
"jest/globals": true
89
},
910

1011
"plugins": [
@@ -14,7 +15,7 @@
1415
"react",
1516
"react-hooks",
1617
"react-native",
17-
"jest",
18+
"jest"
1819
],
1920

2021
// Map from global var to bool specifying if it can be redefined
@@ -50,7 +51,7 @@
5051
"setInterval": false,
5152
"setTimeout": false,
5253
"window": false,
53-
"XMLHttpRequest": false,
54+
"XMLHttpRequest": false
5455
},
5556

5657
"rules": {

babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = {
55
'module-resolver',
66
{
77
alias: {
8-
'@react-native-community/asyns-storage': './lib/AsyncStorage',
8+
'@react-native-community/async-storage': './lib/AsyncStorage',
99
},
1010
cwd: 'babelrc',
1111
},

example/src/App.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,8 @@ export default class App extends Component<Props, State> {
4545
restarting: false,
4646
};
4747

48-
componentDidUpdate() {
49-
if (this.state.restarting) {
50-
this.setState({restarting: false});
51-
}
52-
}
53-
5448
_simulateRestart = () => {
55-
this.setState({restarting: true});
49+
this.setState({restarting: true}, () => this.setState({restarting: false}));
5650
};
5751

5852
render() {
@@ -75,7 +69,7 @@ export default class App extends Component<Props, State> {
7569
{example.description}
7670
</Text>
7771
<View style={styles.exampleInnerContainer}>
78-
{example.render(this._simulateRestart)}
72+
{example.render()}
7973
</View>
8074
</View>
8175
);

example/src/examples/ClearSingle.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,12 @@
1111
import React, {Component} from 'react';
1212
import {Text, View, Button} from 'react-native';
1313

14-
import AsyncStorage from '@react-native-community/asyns-storage';
14+
import AsyncStorage from '@react-native-community/async-storage';
1515

1616
import {STORAGE_KEY} from './GetSet';
1717

18-
type Props = {
19-
resetFunction: () => void,
20-
};
18+
type Props = {};
2119
type State = {
22-
storedNumber: number,
2320
needRestart: boolean,
2421
};
2522
export default class Clear extends Component<Props, State> {

example/src/examples/GetSet.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111
import React, {Component} from 'react';
1212
import {StyleSheet, Text, View, Button} from 'react-native';
1313

14-
import AsyncStorage from '@react-native-community/asyns-storage';
14+
import AsyncStorage from '@react-native-community/async-storage';
1515

16-
type Props = {
17-
resetFunction: () => void,
18-
};
16+
type Props = {};
1917
type State = {
2018
storedNumber: number,
2119
needRestart: boolean,

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@
1919
"url": "https://github.com/react-native-community/react-native-async-storage.git"
2020
},
2121
"scripts": {
22-
"start": "node node_modules/react-native/local-cli/cli.js start"
22+
"start": "node node_modules/react-native/local-cli/cli.js start",
23+
"start:android": "react-native run-android --root example/",
24+
"start:ios": "react-native run-ios --project-path example/ios",
25+
"test": "yarn test:lint && yarn test:flow",
26+
"test:flow": "flow check",
27+
"test:lint": "eslint 'lib/**/*.js' 'example/**/*.js'"
2328
},
2429
"peerDependencies": {
2530
"react": "^16.0",

0 commit comments

Comments
 (0)