Skip to content

Commit deea99c

Browse files
authored
feat: React-native support for auto-env attributes. (#357)
This PR adds auto env support for the react-native sdk.
1 parent cd75210 commit deea99c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2371
-131
lines changed

.eslintrc.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
module.exports = {
22
env: {
33
node: true,
4+
'jest/globals': true,
45
},
56
extends: ['airbnb-base', 'airbnb-typescript/base', 'prettier'],
67
parser: '@typescript-eslint/parser',
78
parserOptions: {
89
project: './tsconfig.eslint.json',
910
},
10-
plugins: ['@typescript-eslint', 'prettier'],
11-
ignorePatterns: ['**/dist/**', '**/vercel/examples/**'],
11+
plugins: ['@typescript-eslint', 'prettier', 'jest'],
12+
ignorePatterns: [
13+
'**/dist/**',
14+
'**/vercel/examples/**',
15+
'**/react-native/example/**',
16+
'**/fromExternal/**',
17+
],
1218
rules: {
1319
'@typescript-eslint/lines-between-class-members': 'off',
1420
'@typescript-eslint/no-unused-vars': [
@@ -20,7 +26,12 @@ module.exports = {
2026
'import/no-extraneous-dependencies': [
2127
'error',
2228
{
23-
devDependencies: ['**/jest*.ts', '**/*.test.ts', '**/rollup.config.ts'],
29+
devDependencies: [
30+
'**/jest*.ts',
31+
'**/*.test.ts',
32+
'**/rollup.config.ts',
33+
'**/*{.,_}{test,spec}.{ts,tsx}',
34+
],
2435
},
2536
],
2637
'import/default': 'error',
@@ -30,5 +41,13 @@ module.exports = {
3041
'import/no-cycle': 'error',
3142
'import/no-useless-path-segments': 'error',
3243
'import/no-duplicates': 'error',
44+
'jest/no-disabled-tests': 'warn',
45+
'jest/no-focused-tests': 'error',
46+
'jest/no-identical-title': 'error',
47+
// 'jest/prefer-to-have-length': 'warn',
48+
'jest/valid-expect': 'error',
49+
},
50+
globals: {
51+
BigInt: 'readonly',
3352
},
3453
};

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,14 @@
3737
},
3838
"devDependencies": {
3939
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
40-
"@typescript-eslint/eslint-plugin": "^6.1.0",
41-
"@typescript-eslint/parser": "^6.1.0",
42-
"eslint": "^8.45.0",
40+
"@typescript-eslint/eslint-plugin": "^6.20.0",
41+
"@typescript-eslint/parser": "^6.20.0",
42+
"eslint": "^8.56.0",
4343
"eslint-config-airbnb-base": "^15.0.0",
4444
"eslint-config-airbnb-typescript": "^17.1.0",
4545
"eslint-config-prettier": "^8.8.0",
4646
"eslint-plugin-import": "^2.27.5",
47+
"eslint-plugin-jest": "^27.6.3",
4748
"eslint-plugin-prettier": "^5.0.0",
4849
"prettier": "^3.0.0",
4950
"typedoc": "0.25.0",

packages/sdk/akamai-base/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,14 @@
5353
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
5454
"@types/crypto-js": "^4.1.1",
5555
"@types/jest": "^29.5.1",
56-
"@typescript-eslint/eslint-plugin": "^6.1.0",
57-
"@typescript-eslint/parser": "^6.1.0",
56+
"@typescript-eslint/eslint-plugin": "^6.20.0",
57+
"@typescript-eslint/parser": "^6.20.0",
5858
"eslint": "^8.45.0",
5959
"eslint-config-airbnb-base": "^15.0.0",
6060
"eslint-config-airbnb-typescript": "^17.1.0",
6161
"eslint-config-prettier": "^8.8.0",
6262
"eslint-plugin-import": "^2.27.5",
63+
"eslint-plugin-jest": "^27.6.3",
6364
"eslint-plugin-prettier": "^5.0.0",
6465
"jest": "^29.5.0",
6566
"launchdarkly-js-test-helpers": "^2.2.0",

packages/sdk/akamai-edgekv/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,14 @@
5353
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
5454
"@types/crypto-js": "^4.1.1",
5555
"@types/jest": "^29.5.1",
56-
"@typescript-eslint/eslint-plugin": "^6.1.0",
57-
"@typescript-eslint/parser": "^6.1.0",
56+
"@typescript-eslint/eslint-plugin": "^6.20.0",
57+
"@typescript-eslint/parser": "^6.20.0",
5858
"eslint": "^8.45.0",
5959
"eslint-config-airbnb-base": "^15.0.0",
6060
"eslint-config-airbnb-typescript": "^17.1.0",
6161
"eslint-config-prettier": "^8.8.0",
6262
"eslint-plugin-import": "^2.27.5",
63+
"eslint-plugin-jest": "^27.6.3",
6364
"eslint-plugin-prettier": "^5.0.0",
6465
"jest": "^29.5.0",
6566
"launchdarkly-js-test-helpers": "^2.2.0",

packages/sdk/cloudflare/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,14 @@
5454
"@types/crypto-js": "^4.1.1",
5555
"@types/jest": "^29.5.0",
5656
"@types/rollup-plugin-generate-package-json": "^3.2.3",
57-
"@typescript-eslint/eslint-plugin": "^6.1.0",
58-
"@typescript-eslint/parser": "^6.1.0",
57+
"@typescript-eslint/eslint-plugin": "^6.20.0",
58+
"@typescript-eslint/parser": "^6.20.0",
5959
"eslint": "^8.45.0",
6060
"eslint-config-airbnb-base": "^15.0.0",
6161
"eslint-config-airbnb-typescript": "^17.1.0",
6262
"eslint-config-prettier": "^8.8.0",
6363
"eslint-plugin-import": "^2.27.5",
64+
"eslint-plugin-jest": "^27.6.3",
6465
"eslint-plugin-prettier": "^5.0.0",
6566
"jest": "^29.5.0",
6667
"launchdarkly-js-test-helpers": "^2.2.0",

packages/sdk/react-native/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ and re-run pod install for [auto-linking to work](https://github.com/react-nativ
4242
// App.tsx
4343
import { LDProvider, ReactNativeLDClient } from '@launchdarkly/react-native-client-sdk';
4444

45-
const featureClient = new ReactNativeLDClient('mobile-key');
45+
const featureClient = new ReactNativeLDClient('mobile-key', AutoEnvAttributes.Enabled);
4646
const userContext = { kind: 'user', key: 'test-user-1' };
4747

4848
const App = () => (
@@ -100,7 +100,7 @@ yarn && yarn ios-go
100100

101101
## Verifying SDK build provenance with the SLSA framework
102102

103-
LaunchDarkly uses the [SLSA framework](https://slsa.dev/spec/v1.0/about) (Supply-chain Levels for Software Artifacts) to help developers make their supply chain more secure by ensuring the authenticity and build integrity of our published SDK packages. To learn more, see the [provenance guide](PROVENANCE.md).
103+
LaunchDarkly uses the [SLSA framework](https://slsa.dev/spec/v1.0/about) (Supply-chain Levels for Software Artifacts) to help developers make their supply chain more secure by ensuring the authenticity and build integrity of our published SDK packages. To learn more, see the [provenance guide](PROVENANCE.md).
104104

105105
## About LaunchDarkly
106106

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: ['module:metro-react-native-babel-preset'],
3+
};

packages/sdk/react-native/example/App.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import { MOBILE_KEY } from '@env';
22

3-
import { LDProvider, ReactNativeLDClient } from '@launchdarkly/react-native-client-sdk';
3+
import {
4+
AutoEnvAttributes,
5+
LDProvider,
6+
ReactNativeLDClient,
7+
} from '@launchdarkly/react-native-client-sdk';
48

59
import Welcome from './src/welcome';
610

7-
const featureClient = new ReactNativeLDClient(MOBILE_KEY);
11+
const featureClient = new ReactNativeLDClient(MOBILE_KEY, AutoEnvAttributes.Enabled);
812

913
const App = () => {
1014
return (

packages/sdk/react-native/example/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"expo-splash-screen": "~0.20.5",
2828
"expo-status-bar": "~1.7.1",
2929
"react": "18.2.0",
30-
"react-native": "0.72.6"
30+
"react-native": "0.72.6",
31+
"react-native-dotenv": "^3.4.9"
3132
},
3233
"devDependencies": {
3334
"@babel/core": "^7.20.0",
@@ -37,7 +38,7 @@
3738
"@types/react": "~18.2.14",
3839
"@types/react-native-dotenv": "^0.2.1",
3940
"detox": "^20.14.7",
40-
"react-native-dotenv": "^3.4.9",
41+
"jest": "^29.7.0",
4142
"ts-jest": "^29.1.1",
4243
"typescript": "^5.2.2"
4344
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"extends": "expo/tsconfig.base",
33
"compilerOptions": {
4+
"jsx": "react",
45
"strict": true,
5-
"typeRoots": ["./types"]
6+
"typeRoots": ["./types"],
67
},
7-
"exclude": ["e2e"]
8+
"exclude": ["e2e"],
89
}

0 commit comments

Comments
 (0)