A boiler plate for React Native, TS, ES Lint, Prettier, Jest
Upgrade all the libs/dependencies to latest before starting off to build actual functionality
$ yarn upgrade-interactive --latest
$ npx react-native init <ProjectName> --template react-native-template-typescript
Open xcode -> <ProjectName>
-> Targets <select ProjectName>
-> General -> Bundle Identifier.
Package name can be updated using "react-native-rename" npm. But this also changing of app name.
4. Add project to git Link
$ git init
$ git add .
$ git commit -m "Initial commit"
$ git remote add origin <remote_repository_URL>
$ git remote -v
$ git push -u origin master
$ yarn add --dev eslint prettier eslint-plugin-react eslint-plugin-import eslint-plugin-jsx-a11y @typescript-eslint/eslint-plugin eslint-config-airbnb-typescript eslint-config-prettier eslint-plugin-prettier husky pretty-quick
Make sure you have ESLint plugin installed for VSCode
And update .eslintrc.js
module.exports = { root: true, extends: ['@react-native-community', 'airbnb-typescript', 'prettier', 'prettier/@typescript-eslint', 'prettier/react'], };
Add rule to suppress v3 of TS Link
rules:['@typescript-eslint/camelcase': 'off',]
Update eslint to include tsconfig.json
parserOptions: {
createDefaultProgram: true,
tsconfigRootDir: __dirname,
project: './tsconfig.json',
},
Additionally update the VSCode Workspace setting, add
"eslint.validate": [ "javascript", "javascriptreact", "typescript", "typescriptreact" ]
Make sure you have Prettier plugin installed for VSCode
{ "singleQuote": true, "trailingComma": "all", }
"exclude": [ "__tests__/**/*-test.ts" ]
9. Enable Hermes engine for android Link
android/app/build.gradle
"enableHermes": true // clean and rebuild if changing
proguard-rules.pro
-keep class com.facebook.hermes.unicode.*_ { _; }
$react-native run-ios / react-native run-android
or
$yarn ios / yarn android
$ git add .
$ git commit -m "Config TS ES prettier"
$ git push
$ npm install --save-dev pretty-quick husky
"husky": { "hooks": { "pre-commit": "pretty-quick --staged && npm run lint" } }
All set!!! build the app using
$react-native run-ios/run-android
or
$yarn android/ios