Skip to content

Commit f42c44d

Browse files
authored
Merge pull request #54 from Naturalclar/feat/addEslint
Add eslint and prettier
2 parents 684c4bb + ca35cd2 commit f42c44d

File tree

9 files changed

+881
-84
lines changed

9 files changed

+881
-84
lines changed

.circleci/config.yml

Lines changed: 67 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,55 +6,59 @@
66
# -------------------------
77

88
aliases:
9-
# -------------------------
10-
# CACHE
11-
# -------------------------
12-
- &restore-yarn-cache
13-
keys:
14-
- yarn-cache-{{ arch }}-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
15-
- yarn-cache-{{ arch }}
9+
# -------------------------
10+
# CACHE
11+
# -------------------------
12+
- &restore-yarn-cache
13+
keys:
14+
- yarn-cache-{{ arch }}-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
15+
- yarn-cache-{{ arch }}
1616

17-
- &save-yarn-cache
18-
paths:
19-
- ~/.cache/yarn
20-
- ~/Library/Detox/ios
21-
key: yarn-cache-{{ arch }}-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
17+
- &save-yarn-cache
18+
paths:
19+
- ~/.cache/yarn
20+
- ~/Library/Detox/ios
21+
key: yarn-cache-{{ arch }}-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
2222

23-
# -------------------------
24-
# INSTALLATION
25-
# -------------------------
26-
- &yarn
27-
name: Yarn Install
28-
command: |
29-
yarn install --network-concurrency 1 --non-interactive --cache-folder ~/.cache/yarn & wait
23+
# -------------------------
24+
# INSTALLATION
25+
# -------------------------
26+
- &yarn
27+
name: Yarn Install
28+
command: |
29+
yarn install --network-concurrency 1 --non-interactive --cache-folder ~/.cache/yarn & wait
3030
31-
# -------------------------
32-
# ANALYSE
33-
# -------------------------
31+
# -------------------------
32+
# ANALYSE
33+
# -------------------------
34+
35+
- &flow
36+
name: Flow Checks
37+
command: yarn test:flow
3438

35-
- &flow
36-
name: Flow Checks
37-
command: yarn test:flow
39+
- &javascript
40+
name: Javascript Tests
41+
command: yarn test:js
3842

39-
- &javascript
40-
name: Javascript Tests
41-
command: yarn test:js
43+
- &eslint
44+
name: Lint
45+
command: yarn lint
4246

4347
# -------------------------
4448
# DEFAULTS
4549
# -------------------------
4650
defaults: &defaults
4751
working_directory: ~/react-native-push-notification-ios
4852
environment:
49-
- GIT_COMMIT_DESC: git log --format=oneline -n 1 $CIRCLE_SHA1
53+
- GIT_COMMIT_DESC: git log --format=oneline -n 1 $CIRCLE_SHA1
5054

5155
# JAVASCRIPT
5256
js_defaults: &js_defaults
5357
<<: *defaults
5458
docker:
55-
- image: circleci/node:8
59+
- image: circleci/node:8
5660
environment:
57-
- PATH: "/opt/yarn/yarn-v1.5.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
61+
- PATH: "/opt/yarn/yarn-v1.5.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
5862

5963
# -------------------------
6064
# JOBS
@@ -65,30 +69,36 @@ jobs:
6569
checkout-code:
6670
<<: *js_defaults
6771
steps:
68-
- checkout
69-
- restore-cache: *restore-yarn-cache
70-
- run: rm -rf node_modules
71-
- run: yarn cache clean
72-
- run: *yarn
73-
- save-cache: *save-yarn-cache
74-
- persist_to_workspace:
75-
root: .
76-
paths: .
72+
- checkout
73+
- restore-cache: *restore-yarn-cache
74+
- run: rm -rf node_modules
75+
- run: yarn cache clean
76+
- run: *yarn
77+
- save-cache: *save-yarn-cache
78+
- persist_to_workspace:
79+
root: .
80+
paths: .
7781

7882
flow:
7983
<<: *js_defaults
8084
steps:
81-
- attach_workspace:
82-
at: ~/react-native-push-notification-ios
83-
- run: *flow
84-
85+
- attach_workspace:
86+
at: ~/react-native-push-notification-ios
87+
- run: *flow
88+
8589
javascript:
8690
<<: *js_defaults
8791
steps:
88-
- attach_workspace:
89-
at: ~/react-native-push-notification-ios
90-
- run: *javascript
92+
- attach_workspace:
93+
at: ~/react-native-push-notification-ios
94+
- run: *javascript
9195

96+
lint:
97+
<<: *js_defaults
98+
steps:
99+
- attach_workspace:
100+
at: ~/react-native-push-notification-ios
101+
- run: *eslint
92102

93103
# -------------------------
94104
# WORK FLOWS
@@ -97,10 +107,13 @@ workflows:
97107
version: 2
98108
Test:
99109
jobs:
100-
- checkout-code
101-
- flow:
102-
requires:
103-
- checkout-code
104-
- javascript:
105-
requires:
106-
- checkout-code
110+
- checkout-code
111+
- flow:
112+
requires:
113+
- checkout-code
114+
- javascript:
115+
requires:
116+
- checkout-code
117+
- lint:
118+
requires:
119+
- checkout-code

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
root: true,
3+
extends: ["@react-native-community"]
4+
};

.prettierrc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
bracketSpacing: false,
3+
jsxBracketSameLine: true,
4+
singleQuote: true,
5+
trailingComma: "all"
6+
};

babel.config.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
module.exports = {
2-
presets: ["module:metro-react-native-babel-preset"],
2+
presets: ['module:metro-react-native-babel-preset'],
33
plugins: [
44
[
5-
"module-resolver",
5+
'module-resolver',
66
{
77
alias: {
8-
"@react-native-community/push-notification-ios": "./js"
8+
'@react-native-community/push-notification-ios': './js',
99
},
10-
cwd: "babelrc"
11-
}
12-
]
13-
]
14-
};
10+
cwd: 'babelrc',
11+
},
12+
],
13+
],
14+
};

example/App.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,13 @@ export default class App extends Component<Props, State> {
8686
label="Send fake local notification"
8787
/>
8888
<Button
89-
onPress={() =>
90-
PushNotificationIOS.setApplicationIconBadgeNumber(42)
91-
}
92-
label="Set app's icon badge to 42"
93-
/>
94-
<Button
95-
onPress={() => PushNotificationIOS.setApplicationIconBadgeNumber(0)}
96-
label="Clear app's icon badge"
97-
/>
89+
onPress={() => PushNotificationIOS.setApplicationIconBadgeNumber(42)}
90+
label="Set app's icon badge to 42"
91+
/>
92+
<Button
93+
onPress={() => PushNotificationIOS.setApplicationIconBadgeNumber(0)}
94+
label="Clear app's icon badge"
95+
/>
9896
<View>
9997
<Button
10098
onPress={this._showPermissions.bind(this)}
@@ -122,7 +120,7 @@ export default class App extends Component<Props, State> {
122120
_sendLocalNotification() {
123121
PushNotificationIOS.presentLocalNotification({
124122
alertBody: 'Sample local notification',
125-
applicationIconBadgeNumber: 1
123+
applicationIconBadgeNumber: 1,
126124
});
127125
}
128126

@@ -187,7 +185,6 @@ export default class App extends Component<Props, State> {
187185
}
188186
}
189187

190-
191188
const styles = StyleSheet.create({
192189
container: {
193190
flex: 1,

js/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
'use strict';
1212

13-
import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
13+
import {NativeEventEmitter, NativeModules} from 'react-native';
1414
import invariant from 'invariant';
1515

16-
const { RNCPushNotificationIOS } = NativeModules;
16+
const {RNCPushNotificationIOS} = NativeModules;
1717

1818
const PushNotificationEmitter = new NativeEventEmitter(RNCPushNotificationIOS);
1919

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"start": "node node_modules/react-native/local-cli/cli.js start",
1212
"test": "yarn test:flow && yarn test:js",
1313
"test:flow": "flow check",
14-
"test:js": "echo 0"
14+
"test:js": "echo 0",
15+
"lint": "eslint ."
1516
},
1617
"keywords": [
1718
"react-native",
@@ -30,12 +31,16 @@
3031
},
3132
"devDependencies": {
3233
"@babel/core": "^7.0.0",
34+
"@react-native-community/eslint-config": "^0.0.5",
3335
"babel-core": "^7.0.0-bridge.0",
3436
"babel-jest": "24.1.0",
3537
"babel-plugin-module-resolver": "^3.1.3",
38+
"eslint": "^6.8.0",
39+
"eslint-plugin-prettier": "^3.1.2",
3640
"flow-bin": "^0.86.0",
3741
"jest": "24.1.0",
3842
"metro-react-native-babel-preset": "0.51.1",
43+
"prettier": "^1.19.1",
3944
"react": "16.6.3",
4045
"react-native": "0.58.4"
4146
},

0 commit comments

Comments
 (0)