Skip to content

Commit c0f1f77

Browse files
jevakallioanp
authored andcommitted
Add .flowconfig and instructions to enable Flow (#80)
* Import .flowconfig from [email protected] template https://raw.githubusercontent.com/facebook/react-native/0.41-stable/local-cli/templates/HelloWorld/_flowconfig * Add additional CRNA-specific ignores * Add "Adding Flow" section to readme (lifted from CRA readme) * Add release checklist * Add a disclaimer about current RELEASES doc status * Move "Adding Flow" section to generated README - Fix relative file paths - Remove Nuclide link (users can figure this out for themselves)
1 parent a52eac9 commit c0f1f77

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed

RELEASES.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Releasing Create React Native App
2+
3+
This document contains checklists to be done before releasing new versions.
4+
5+
**TODO**: This is not an exhaustive list. At the moment it contains easy-to-forget steps, so that they would not be forgotten.
6+
7+
## Verify .flowconfig is up to date after updating expo-sdk
8+
9+
After upgrading the [expo-sdk](https://github.com/exponent/exponent-sdk) version (which transitively updates the `react-native` version), ensure that the [.flowconfig](react-native-scripts/template/.flowconfig) template is up to date.
10+
11+
Easiest way to do this, is:
12+
1. Use [this handy chart](VERSIONS.md) to find out the underlying `react-native` versions of the old and new `expo-sdk`.
13+
2. Get `react-native` .flowconfig changeset in the React Native repo with `git diff tags/v0.41.0 tags/v0.42.0 -- local-cli/templates/HelloWorld/_flowconfig`
14+
3. If there are changes, land diff to CRNA [.flowconfig](react-native-scripts/template/.flowconfig) template
15+
4. To test, follow instructions in [README/Adding Flow](react-native-scripts/README.md#adding-flow) on a freshly generated project, and do `npm run flow` to ensure the process exits without error.
16+
5. If there are new issues with third-party dependencies, fix them upstream or add necessary `[ignore]` fields to .flowconfig.
+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
[ignore]
2+
; We fork some components by platform
3+
.*/*[.]android.js
4+
5+
; Ignore "BUCK" generated dirs
6+
<PROJECT_ROOT>/\.buckd/
7+
8+
; Ignore unexpected extra "@providesModule"
9+
.*/node_modules/.*/node_modules/fbjs/.*
10+
11+
; Ignore duplicate module providers
12+
; For RN Apps installed via npm, "Libraries" folder is inside
13+
; "node_modules/react-native" but in the source repo it is in the root
14+
.*/Libraries/react-native/React.js
15+
.*/Libraries/react-native/ReactNative.js
16+
17+
; Additional create-react-native-app ignores
18+
19+
; Ignore duplicate module providers
20+
.*/node_modules/fbemitter/lib/*
21+
22+
; Ignore misbehaving dev-dependencies
23+
.*/node_modules/xdl/build/*
24+
.*/node_modules/reqwest/tests/*
25+
26+
; Ignore missing expo-sdk dependencies (temporarily)
27+
; https://github.com/exponent/exponent-sdk/issues/36
28+
.*/node_modules/expo/src/*
29+
30+
[include]
31+
32+
[libs]
33+
node_modules/react-native/Libraries/react-native/react-native-interface.js
34+
node_modules/react-native/flow
35+
flow/
36+
37+
[options]
38+
module.system=haste
39+
40+
experimental.strict_type_args=true
41+
42+
munge_underscores=true
43+
44+
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
45+
46+
suppress_type=$FlowIssue
47+
suppress_type=$FlowFixMe
48+
suppress_type=$FixMe
49+
50+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-7]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
51+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-7]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
52+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
53+
54+
unsafe.enable_getters_and_setters=true
55+
56+
[version]
57+
^0.37.0

react-native-scripts/template/README.md

+19
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Below you'll find information about performing common tasks. The most recent ver
1212
* [npm run android](#npm-run-android)
1313
* [npm run eject](#npm-run-eject)
1414
* [Writing and Running Tests](#writing-and-running-tests)
15+
* [Adding Flow](#adding-flow)
1516
* [Customizing App Display Name and Icon](#customizing-app-display-name-and-icon)
1617
* [Sharing and Deployment](#sharing-and-deployment)
1718
* [Publishing to Expo's React Native Community](#publishing-to-expos-react-native-community)
@@ -69,6 +70,24 @@ To set an app icon, set the `expo.icon` key in `app.json` to be either a local p
6970

7071
This project is set up to use [jest](https://facebook.github.io/jest/) for tests. You can configure whatever testing strategy you like, but jest works out of the box. Create test files in directories called `__tests__` to have the files loaded by jest. See the [the template project](https://github.com/react-community/create-react-native-app/tree/master/react-native-scripts/template/__tests__) for an example test. The [jest documentation](https://facebook.github.io/jest/docs/getting-started.html) is also a wonderful resource, as is the [React Native testing tutorial](https://facebook.github.io/jest/docs/tutorial-react-native.html).
7172

73+
## Adding Flow
74+
75+
Flow is a static type checker that helps you write code with fewer bugs. Check out this [introduction to using static types in JavaScript](https://medium.com/@preethikasireddy/why-use-static-types-in-javascript-part-1-8382da1e0adb) if you are new to this concept.
76+
77+
React Native works with [Flow](http://flowtype.org/) out of the box, as long as your Flow version matches the one used in the version of React Native.
78+
79+
To add a local dependency to the correct Flow version to a Create React Native App project, follow these steps:
80+
81+
1. Find the Flow `[version]` at the bottom of the included [.flowconfig](.flowconfig)
82+
2. Run `npm install --save-dev [email protected]` (or `yarn add --dev [email protected]`), where `x.y.z` is the .flowconfig version number.
83+
3. Add `"flow": "flow"` to the `scripts` section of your `package.json`.
84+
4. Add `// @flow` to any files you want to type check (for example, to `App.js`).
85+
86+
Now you can run `npm run flow` (or `yarn flow`) to check the files for type errors.
87+
You can optionally use a plugin for your IDE for a better integrated experience.
88+
89+
To learn more about Flow, check out [its documentation](https://flowtype.org/).
90+
7291
## Sharing and Deployment
7392

7493
Create React Native App does a lot of work to make app setup and development simple and straightforward, but it's very difficult to do the same for deploying to Apple's App Store or Google's Play Store without relying on a hosted service.

0 commit comments

Comments
 (0)