Skip to content

Commit 50e2423

Browse files
Merge pull request #53 from rootstrap/upstream-to-pr/rev-f17813e
Upstream branch master (revision f17813e)
2 parents 7d762be + f8260d5 commit 50e2423

23 files changed

+3783
-3747
lines changed

.eslintrc.js

Lines changed: 52 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -3,104 +3,77 @@ const path = require('path');
33
module.exports = {
44
// Configuration for JavaScript files
55
extends: [
6-
'@react-native-community',
7-
'plugin:prettier/recommended',
8-
'plugin:sonarjs/recommended-legacy',
6+
'expo',
7+
'plugin:tailwindcss/recommended',
8+
'prettier'
99
],
10-
plugins: ['unicorn', 'sonarjs'],
10+
plugins: [
11+
'unicorn',
12+
'@typescript-eslint',
13+
'unused-imports',
14+
'tailwindcss',
15+
'simple-import-sort',
16+
'sonarjs'
17+
],
18+
parserOptions: {
19+
project: './tsconfig.json',
20+
},
1121
rules: {
1222
'@typescript-eslint/no-explicit-any': 'error',
13-
'prettier/prettier': [
14-
'error',
15-
{
16-
singleQuote: true,
17-
endOfLine: 'auto',
18-
},
19-
],
2023
'unicorn/filename-case': [
2124
'error',
2225
{
2326
case: 'kebabCase',
2427
ignore: ['/android', '/ios'],
2528
},
2629
],
30+
'max-params': ['error', 3], // Limit the number of parameters in a function to use object instead
31+
'max-lines-per-function': ['error', 70],
32+
'react/display-name': 'off',
33+
'react/no-inline-styles': 'off',
34+
'react/destructuring-assignment': 'off', // Vscode doesn't support automatically destructuring, it's a pain to add a new variable
35+
'react/require-default-props': 'off', // Allow non-defined react props as undefined
36+
'@typescript-eslint/comma-dangle': 'off', // Avoid conflict rule between Eslint and Prettier
37+
'@typescript-eslint/consistent-type-imports': [
38+
'warn',
39+
{
40+
prefer: 'type-imports',
41+
fixStyle: 'inline-type-imports',
42+
disallowTypeAnnotations: true,
43+
},
44+
], // Ensure `import type` is used when it's necessary
45+
'import/prefer-default-export': 'off', // Named export is easier to refactor automatically
46+
'import/no-cycle': ['error', { maxDepth: '∞' }],
47+
'tailwindcss/classnames-order': [
48+
'warn',
49+
{
50+
officialSorting: true,
51+
},
52+
], // Follow the same ordering as the official plugin `prettier-plugin-tailwindcss`
53+
'simple-import-sort/imports': 'error', // Import configuration for `eslint-plugin-simple-import-sort`
54+
'simple-import-sort/exports': 'error', // Export configuration for `eslint-plugin-simple-import-sort`
55+
'@typescript-eslint/no-unused-vars': 'off',
56+
'@typescript-eslint/array-type': 'off',
57+
'tailwindcss/no-custom-classname': 'off',
58+
'unused-imports/no-unused-imports': 'error',
59+
'unused-imports/no-unused-vars': [
60+
'error',
61+
{
62+
argsIgnorePattern: '^_',
63+
varsIgnorePattern: '^_',
64+
caughtErrorsIgnorePattern: '^_',
65+
}
66+
],
2767
curly: [2, 'all'],
2868
'prefer-const': [
2969
'error',
3070
{
3171
destructuring: 'any',
3272
},
3373
],
74+
'object-shorthand': 'error'
3475
},
3576
overrides: [
36-
// Configuration for TypeScript files
37-
{
38-
files: ['**/*.ts', '**/*.tsx', '**/*.js'],
39-
plugins: [
40-
'@typescript-eslint',
41-
'unused-imports',
42-
'tailwindcss',
43-
'simple-import-sort',
44-
],
45-
extends: [
46-
'plugin:tailwindcss/recommended',
47-
'@react-native-community',
48-
'plugin:prettier/recommended',
49-
],
50-
parserOptions: {
51-
project: './tsconfig.json',
52-
},
53-
rules: {
54-
'react/react-in-jsx-scope': 'off',
55-
'react/jsx-uses-react': 'off',
56-
'prettier/prettier': [
57-
'error',
58-
{
59-
singleQuote: true,
60-
endOfLine: 'auto',
61-
},
62-
],
63-
'max-params': ['error', 3], // Limit the number of parameters in a function to use object instead
64-
'max-lines-per-function': ['error', 70],
65-
'react/destructuring-assignment': 'off', // Vscode doesn't support automatically destructuring, it's a pain to add a new variable
66-
'react/require-default-props': 'off', // Allow non-defined react props as undefined
67-
'@typescript-eslint/comma-dangle': 'off', // Avoid conflict rule between Eslint and Prettier
68-
'@typescript-eslint/consistent-type-imports': 'error', // Ensure `import type` is used when it's necessary
69-
'import/prefer-default-export': 'off', // Named export is easier to refactor automatically
70-
'tailwindcss/classnames-order': [
71-
'warn',
72-
{
73-
officialSorting: true,
74-
},
75-
], // Follow the same ordering as the official plugin `prettier-plugin-tailwindcss`
76-
'simple-import-sort/imports': 'error', // Import configuration for `eslint-plugin-simple-import-sort`
77-
'simple-import-sort/exports': 'error', // Export configuration for `eslint-plugin-simple-import-sort`
78-
'@typescript-eslint/no-unused-vars': 'off',
79-
'tailwindcss/no-custom-classname': 'off',
80-
'unused-imports/no-unused-imports': 'error',
81-
'unused-imports/no-unused-vars': [
82-
'error',
83-
{
84-
argsIgnorePattern: '^_',
85-
varsIgnorePattern: '^_',
86-
caughtErrorsIgnorePattern: '^_',
87-
},
88-
],
89-
'no-restricted-imports': [
90-
'error',
91-
{
92-
paths: [
93-
{
94-
name: 'react',
95-
importNames: ['default'],
96-
message: 'No need to import React',
97-
},
98-
],
99-
},
100-
],
101-
curly: [2, 'all'],
102-
},
103-
},
10477
// Configuration for translations files (i18next)
10578
{
10679
files: ['src/translations/*.json'],

docs/astro.config.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ export default defineConfig({
190190
},
191191
],
192192
},
193+
{
194+
label: 'Libraries Recommendation',
195+
link: '/libraries-recommendation',
196+
},
193197
{
194198
label: 'CHANGELOG',
195199
link: '/changelog',

docs/src/content/docs/changelog.md

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,7 @@ title: CHANGELOG
33
description: New features, improvements, and bug fixes for the React Native / Expo Starter.
44
head:
55
- tag: title
6-
content: Obytes Starter ChangeLog | React Native / Expo Starter
6+
content: Rootstrap Starter ChangeLog | React Native / Expo Starter
77
---
88

9-
## V5.0.0
10-
11-
- Upgrade to Expo 50
12-
- Switch to `expo-router` for navigation
13-
- Upgrade to NativeWind 4.0
14-
- Refactor `ui` and update common components to use NativeWind 4.0 with `tailwind-variants`
15-
- Add checkbox, radio, and switch components
16-
- Improve eas setup with PNPM
9+
For complete changelog, please check the [GitHub releases](https://github.com/rootstrap/react-native-template/releases) page.

docs/src/content/docs/getting-started/environment-vars-config.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ const _buildTimeEnv = {
6969
NEW_ENV_VAR=my-new-var
7070
```
7171

72+
::: note
73+
if you are not pushing env files to your repo(recomended), please make sure to check the [App releasing process](/ci-cd/app-releasing-process/#github-action-and-env-variables) to see how to create the env file on the fly before the prebuild script in the github actions.
74+
:::
75+
7276
4. Make sure to run `pnpm prebuild` to load the new values.
7377

7478
```bash
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
title: Libraries Recommendation
3+
description: React Native / Expo Libraries recommendation for the project based on use cases.
4+
head:
5+
- tag: title
6+
content: Libraries Recommendation | React Native / Expo Starter
7+
---
8+
9+
The starter kit comes with a set of pre-installed and configured libraries. We recommend using these libraries for your project.
10+
11+
Below, we'll list other libraries we often use in our projects. These aren't included in the starter because:
12+
13+
1. They're for specific use cases.
14+
2. They need a lot of setup.
15+
16+
This way, you can add them to your project only if you need them, keeping things simple to start with.
17+
18+
### State Management:
19+
20+
The starter kit comes with Zustand out of the box but if your application implements a lot of workflows, you might want to use [XState](https://xstate.js.org/) as it's more powerful on managing complex workflows and state machines.
21+
22+
For example, if you have a workflow to create a new card for user and this workflow has a lot of steps and conditions, Zustand might not be the best choice as it's more designed for simple state management and XState is your best choice in this case.
23+
24+
### Error Reporting:
25+
26+
- [Sentry](https://sentry.io/welcome/): very popular solution for error reporting in the javascript ecosystem and has a great integration with Expo.
27+
28+
### Notifications:
29+
30+
There is no solution fit all for notifications, but based on your use case we would recommend one of the following:
31+
32+
- [Expo Push Notifications](https://docs.expo.dev/push-notifications/overview/)
33+
- [OneSignal](https://onesignal.com/)
34+
35+
### Analytics:
36+
37+
- [PostHog](https://posthog.com/docs/libraries/react-native) : Easy to setup and use and has a great free tier.
38+
39+
- [Google Analytics](https://rnfirebase.io/analytics/usage)
40+
41+
### Charts:
42+
43+
- [Victory Native](https://github.com/FormidableLabs/victory-native-xl)
44+
45+
---
46+
47+
For sure we are missing some great libraries here, so we count on your contribution to add them in the comments sections below.

env.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-env node */
12
/*
23
* Env file to load and validate env variables
34
* Be cautious; this file should not be imported into your source folder. TODO: Add an eslint rule to prevent this.
@@ -54,8 +55,14 @@ const isRunning = EXPO_RUN_COMMANDS.some((script) =>
5455
const shouldValidateEnv =
5556
(isBuilding && scriptIsEnvironmentDependant) || isRunning;
5657

57-
const easEnvironmentFileVariable = `ENVIRONMENT_FILE_${APP_ENV.toUpperCase()}`;
58-
const easEnvironmentFilePath = process.env[easEnvironmentFileVariable];
58+
const environmentFiles = {
59+
development: process.env.ENVIRONMENT_FILE_DEVELOPMENT,
60+
qa: process.env.ENVIRONMENT_FILE_QA,
61+
production: process.env.ENVIRONMENT_FILE_PRODUCTION,
62+
staging: process.env.ENVIRONMENT_FILE_STAGING,
63+
};
64+
65+
const easEnvironmentFilePath = environmentFiles[APP_ENV];
5966
const localEnvironmentFilePath = path.resolve(__dirname, `.env.${APP_ENV}`);
6067

6168
const envPath = isEASBuild ? easEnvironmentFilePath : localEnvironmentFilePath;
@@ -191,7 +198,7 @@ if (shouldValidateEnv) {
191198
const parsedWholeEnv = wholeEnvSchema.safeParse(_wholeEnv);
192199

193200
if (parsedWholeEnv.success === false) {
194-
const envFile = isEASBuild ? easEnvironmentFileVariable : `.env.${APP_ENV}`;
201+
const envFile = isEASBuild ? environmentFiles[APP_ENV] : `.env.${APP_ENV}`;
195202

196203
const messages = [
197204
'❌ Invalid environment variables:',
@@ -208,7 +215,7 @@ if (shouldValidateEnv) {
208215

209216
if (isEASBuild) {
210217
messages.push(
211-
`\n☁️ For \x1b[1m\x1b[32mEAS Build\x1b[0m deployments, ensure the secret\x1b[1m\x1b[4m\x1b[31m${easEnvironmentFileVariable} \x1b[0m is defined in Project Secrets and has the proper environment file attached.`
218+
`\n☁️ For \x1b[1m\x1b[32mEAS Build\x1b[0m deployments, ensure the secret\x1b[1m\x1b[4m\x1b[31m${environmentFiles[APP_ENV]} \x1b[0m is defined in Project Secrets and has the proper environment file attached.`
212219
);
213220
}
214221

index.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

setup.ts renamed to jest-setup.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import '@testing-library/react-native/extend-expect';
2+
13
// react-hook form setup for testing
24
// @ts-ignore
35
global.window = {};

jest.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
module.exports = {
22
preset: 'jest-expo',
33
setupFilesAfterEnv: [
4-
'@testing-library/react-native/extend-expect',
5-
'<rootDir>/setup.ts',
4+
'<rootDir>/jest-setup.ts',
65
],
76
testMatch: ['**/?(*.)+(spec|test).ts?(x)'],
87
collectCoverageFrom: [

metro.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-env node */
2+
13
const { getDefaultConfig } = require('expo/metro-config');
24
const { withNativeWind } = require('nativewind/metro');
35

0 commit comments

Comments
 (0)