- Flow
- ESLint
- Prettier
- VSCode
-
Init React Native project
$ react-native init HelloPGP $ cd HelloPGP/
-
Init git repo
$ git init $ git add --all && git commit -m "Initial commit"
-
Install Flow
Flow compiler
$ brew install flow # Flow compiler $ yarn add --dev babel-cli babel-preset-flow
Add "flow" to .babelrc presets.
.babelrc
should look like this:{ "presets": ["react-native", "flow"], "retainLines": true }
Flow
# Flow $ yarn add --dev flow-bin $ vim package.json
Add the following flow entries to the package.json:
{ "scripts": { "flow": "flow", "flow-stop": "flow stop" } }
-
VSCode
- Install extension Flow Language Support.
-
ESLint with Babel-Parser
We will use the eslint-config-airbnb Package. But first, we need to install its peer dependencies.
( export PKG=eslint-config-airbnb-base; npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs yarn add --dev "$PKG@latest" )
Install babel-eslint.
$ yarn add --dev babel-eslint
Create an
.eslintrc.json
file and copy the following configuration:{ "parser": "babel-eslint", "extends": "airbnb", "plugins": ["react", "jsx-a11y", "import"] }
-
Prettier
$ yarn add --dev prettier-eslint
-
VSCode
Add the following workspace settings:
{ // Format a file on save. A formatter must be available, the file must not be auto-saved, and editor must not be shutting down. "editor.formatOnSave": true, // Support using flow through your node_modules folder, WARNING: Checking this box is a security risk. When you open a project we will immediately run code contained within it. "flow.useNPMPackagedFlow": true, // Enable/disable JavaScript validation. (For Flow) "javascript.validate.enable": false, // Enable/disable default JavaScript formatter (For Prettier) "javascript.format.enable": false, // Use 'prettier-eslint' instead of 'prettier'. Other settings will only be fallbacks in case they could not be inferred from eslint rules. "prettier.eslintIntegration": true }
This guide is based on: