Skip to content

Commit 9f694f0

Browse files
author
Krzysztof Borowy
authored
chore: Scaffold Core repo (#1006)
* scaffold * unify storage setup * remove root from root tsconfig * comments
1 parent 0fc2f28 commit 9f694f0

14 files changed

+235
-102
lines changed

.eslintrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": ["@react-native-community"],
3+
"rules": {
4+
"no-console": "error"
5+
}
6+
}

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ DerivedData
2828
*.xcuserstate
2929
local.properties
3030
*.iml
31+
32+
#workspaces
33+
/packages/*/lib

.prettierrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"tabWidth": 2,
3+
"semi": true,
4+
"singleQuote": true,
5+
"bracketSpacing": true,
6+
"parser": "typescript"
7+
}

package.json

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
"packages/*"
66
],
77
"packageManager": "[email protected]",
8+
"devDependencies": {
9+
"@react-native-community/eslint-config": "3.2.0",
10+
"eslint": "8.26.0",
11+
"prettier": "2.5.1",
12+
"typescript": "4.9.5"
13+
},
814
"resolutions": {
915
"@react-native-community/cli": "^10.2.5",
1016
"@react-native-community/cli-platform-android": "^10.2.0",

packages/core/.eslintrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "../../.eslintrc"
3+
}

packages/core/package.json

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"name": "@react-native-async-storage/core",
3+
"version": "0.0.0",
4+
"description": "Core API of Async Storage",
5+
"source": "src/index.ts",
6+
"react-native": "src/index.ts",
7+
"types": "lib/typescript/index.d.ts",
8+
"exports": {
9+
"import": "./lib/module/index.js",
10+
"require": "./lib/commonjs/index.js"
11+
},
12+
"files": [
13+
"src",
14+
"lib"
15+
],
16+
"scripts": {
17+
"prepack": "yarn build",
18+
"build": "bob build",
19+
"test:lint": "eslint src/**",
20+
"test:ts": "tsc --noEmit"
21+
},
22+
"keywords": [
23+
"react-native",
24+
"async-storage",
25+
"storage",
26+
"api",
27+
"core api"
28+
],
29+
"repository": "https://github.com/react-native-async-storage/async-storage/blob/main/packages/core",
30+
"author": "Krzysztof Borowy <[email protected]>",
31+
"license": "MIT",
32+
"devDependencies": {
33+
"eslint": "8.26.0",
34+
"react-native-builder-bob": "0.20.0",
35+
"typescript": "4.9.5"
36+
},
37+
"react-native-builder-bob": {
38+
"source": "src",
39+
"output": "lib",
40+
"targets": [
41+
"commonjs",
42+
"module",
43+
"typescript"
44+
]
45+
}
46+
}

packages/core/src/index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function double(i: number) {
2+
return i * i;
3+
}
4+
5+
double(6);

packages/core/tsconfig.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"include": ["./src/**/*"]
4+
}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": [
3+
"../../.eslintrc",
4+
"plugin:wdio/recommended"
5+
],
6+
"plugins": ["wdio"],
7+
"rules": {
8+
"dot-notation": "off"
9+
}
10+
}

packages/default-storage-backend/package.json

+2-28
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
"devDependencies": {
7373
"@babel/core": "^7.20.0",
7474
"@babel/preset-env": "^7.20.0",
75-
"@react-native-community/eslint-config": "^3.0.0",
7675
"@semantic-release/changelog": "^6.0.0",
7776
"@semantic-release/git": "^10.0.0",
7877
"@types/lodash": "^4.14.184",
@@ -87,11 +86,11 @@
8786
"appium-uiautomator2-driver": "^2.26.2",
8887
"appium-xcuitest-driver": "^4.32.5",
8988
"concurrently": "^6.4.0",
90-
"eslint": "^8.0.0",
89+
"eslint": "8.26.0",
9190
"eslint-plugin-wdio": "^8.8.7",
9291
"expo": "^48.0.0",
9392
"lodash": "^4.17.21",
94-
"prettier": "^2.5.1",
93+
"prettier": "2.5.1",
9594
"react": "18.2.0",
9695
"react-dom": "^18.2.0",
9796
"react-native": "^0.71.0",
@@ -106,31 +105,6 @@
106105
"typescript": "^4.9.4",
107106
"webdriverio": "^8.11.2"
108107
},
109-
"eslintConfig": {
110-
"root": true,
111-
"plugins": [
112-
"wdio"
113-
],
114-
"extends": [
115-
"@react-native-community",
116-
"plugin:wdio/recommended"
117-
],
118-
"rules": {
119-
"dot-notation": "off"
120-
}
121-
},
122-
"prettier": {
123-
"endOfLine": "auto",
124-
"singleQuote": true,
125-
"overrides": [
126-
{
127-
"files": "*.md",
128-
"options": {
129-
"proseWrap": "always"
130-
}
131-
}
132-
]
133-
},
134108
"react-native-builder-bob": {
135109
"source": "src",
136110
"output": "lib",

packages/default-storage-backend/src/helpers.ts

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export function checkValidInput(...input: unknown[]) {
2828
const [key, value] = input;
2929

3030
if (typeof key !== 'string') {
31+
// eslint-disable-next-line no-console
3132
console.warn(
3233
`[AsyncStorage] Using ${typeof key} type for key is not supported. This can lead to unexpected behavior/errors. Use string instead.\nKey passed: ${key}\n`
3334
);
@@ -39,6 +40,7 @@ export function checkValidInput(...input: unknown[]) {
3940
`[AsyncStorage] Passing null/undefined as value is not supported. If you want to remove value, Use .removeItem method instead.\nPassed value: ${value}\nPassed key: ${key}\n`
4041
);
4142
} else {
43+
// eslint-disable-next-line no-console
4244
console.warn(
4345
`[AsyncStorage] The value for key "${key}" is not a string. This can lead to unexpected behavior/errors. Consider stringifying it.\nPassed value: ${value}\nPassed key: ${key}\n`
4446
);

packages/default-storage-backend/tsconfig.build.json

+1-18
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
11
{
2-
"compilerOptions": {
3-
"noFallthroughCasesInSwitch": true,
4-
"noImplicitOverride": true,
5-
"noImplicitReturns": true,
6-
"noPropertyAccessFromIndexSignature": true,
7-
"noUnusedLocals": true,
8-
"noUnusedParameters": true,
9-
"strict": true,
10-
"moduleResolution": "Node",
11-
"resolveJsonModule": true,
12-
"allowJs": true,
13-
"checkJs": true,
14-
"allowSyntheticDefaultImports": true,
15-
"forceConsistentCasingInFileNames": true,
16-
"jsx": "react",
17-
"target": "ESNext",
18-
"skipLibCheck": true
19-
},
2+
"extends": "../../tsconfig.base.json",
203
"include": [
214
"src"
225
]

tsconfig.base.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"exclude": ["node_modules"],
3+
"compilerOptions": {
4+
"noFallthroughCasesInSwitch": true,
5+
"noImplicitOverride": true,
6+
"noImplicitReturns": true,
7+
"noPropertyAccessFromIndexSignature": true,
8+
"noUnusedLocals": true,
9+
"noUnusedParameters": true,
10+
"strict": true,
11+
"moduleResolution": "node",
12+
"resolveJsonModule": true,
13+
"allowJs": true,
14+
"checkJs": true,
15+
"allowSyntheticDefaultImports": true,
16+
"forceConsistentCasingInFileNames": true,
17+
"jsx": "react",
18+
"target": "ESNext",
19+
"skipLibCheck": true
20+
}
21+
}

0 commit comments

Comments
 (0)