-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstarter.sh
executable file
·130 lines (118 loc) · 3.64 KB
/
starter.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
PROJECT_NAME=$1
RN_VERSION=$2
if [ -z "$RN_VERSION" ]
then react-native init $PROJECT_NAME
else
react-native init $PROJECT_NAME --version react-native@"$RN_VERSION"
fi
PROJECT_PATH=`cd "$PROJECT_NAME"; pwd`
if [ -e "$PROJECT_PATH/.eslintrc.json" ]
then echo ".eslintrc.json already exists"
else
echo "
{
\"parser\": \"babel-eslint\",
\"parserOptions\": {
\"ecmaVersion\": 6,
\"sourceType\": \"module\",
\"ecmaFeatures\": {
\"jsx\": true
}
},
\"env\": {
\"es6\": true,
\"jest\": true,
\"browser\": true,
\"node\": true
},
\"plugins\": [
\"react\",
\"jsx-a11y\",
\"flowtype\"
],
\"rules\": {
// This to avoid an error from flow types with prefix \`_t_\`
\"camelcase\": 0,
// This to avoid an error that all files with jsx must be with extension \`jsx\`
\"react/jsx-filename-extension\": 0,
// Avoid error when defined flow types for props at the top of the class
\"react/sort-comp\": 0,
// Disable error: absolute imports should come before relative imports.
\"import/first\": 0,
// Disable error: do not import modules using an absolute path
\"import/no-absolute-path\": 0,
// Allow imports without extensions
\"import/extensions\": 0,
// Change error to warning for: prefer default export (when export one item
// from file - prefer to use \`default export\` instead of \`export\`)
\"import/prefer-default-export\": 0,
// disallow trailing commas in object literals
\"comma-dangle\": 0,
// Disable rule: strings must use singlequote.
\"quotes\": 0,
\"no-console\": [
\"warn\",
{
\"allow\": [
\"warn\",
\"error\",
\"info\"
]
}
],
// Allow to start name of variables and functions from underscore
\"no-underscore-dangle\": 0,
// Maximum line length
\"max-len\": [
\"warn\",
120
],
// Disable rule: expected the Promise rejection reason to be an Error.
// It not allow explicitly return promise reject without error provided
\"max-lines\": [
\"warn\",
300
],
\"prefer-promise-reject-errors\": 0,
// TODO: find solution for resolve paths for import
// For now disable error: unable to resolve path to module
// It be handled by flow
\"import/no-unresolved\": 0,
// Allows first line in block to be empty
\"padded-blocks\": 0,
// Allow use unary operators
\"no-plusplus\": 0,
// Allow to use hasOwnProperty
\"no-prototype-builtin\": 0,
// Allow to not define default props for not required props
\"react/require-default-props\": 0
},
\"extends\": [
\"airbnb\",
\"plugin:flowtype/recommended\"
]
}
" > "$PROJECT_PATH/.eslintrc.json"
fi
cd $PROJECT_PATH
PATH="/usr/local/bin/:$PATH"
FLOW_CONFIG_VERSION=$(tail -n 1 ".flowconfig");
yarn add -D \
babel-eslint \
eslint \
eslint-plugin-react \
eslint-plugin-react-native \
eslint-plugin-jsx-a11y \
husky \
eslint-plugin-import \
eslint-config-airbnb \
flow-bin@$FLOW_CONFIG_VERSION \
eslint-plugin-flowtype
sed -i.bak '/emoji=true/a\
esproposal.decorators=ignore' ".flowconfig"
sed -i.bak '/"scripts": {/a\
\ "lint": "eslint ./src",\
\ "flow": "node_modules/.bin/flow",\
\ "precommit": "npm run lint && npm run test",\
\ "prepush": "npm run lint && npm run test",\
' "package.json"