Skip to content

Commit

Permalink
chore: Scaffold Core repo (#1006)
Browse files Browse the repository at this point in the history
* scaffold

* unify storage setup

* remove root from root tsconfig

* comments
  • Loading branch information
Krzysztof Borowy authored Aug 31, 2023
1 parent 0fc2f28 commit 9f694f0
Show file tree
Hide file tree
Showing 14 changed files with 235 additions and 102 deletions.
6 changes: 6 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": ["@react-native-community"],
"rules": {
"no-console": "error"
}
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ DerivedData
*.xcuserstate
local.properties
*.iml

#workspaces
/packages/*/lib
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"bracketSpacing": true,
"parser": "typescript"
}
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
"packages/*"
],
"packageManager": "[email protected]",
"devDependencies": {
"@react-native-community/eslint-config": "3.2.0",
"eslint": "8.26.0",
"prettier": "2.5.1",
"typescript": "4.9.5"
},
"resolutions": {
"@react-native-community/cli": "^10.2.5",
"@react-native-community/cli-platform-android": "^10.2.0",
Expand Down
3 changes: 3 additions & 0 deletions packages/core/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../../.eslintrc"
}
46 changes: 46 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "@react-native-async-storage/core",
"version": "0.0.0",
"description": "Core API of Async Storage",
"source": "src/index.ts",
"react-native": "src/index.ts",
"types": "lib/typescript/index.d.ts",
"exports": {
"import": "./lib/module/index.js",
"require": "./lib/commonjs/index.js"
},
"files": [
"src",
"lib"
],
"scripts": {
"prepack": "yarn build",
"build": "bob build",
"test:lint": "eslint src/**",
"test:ts": "tsc --noEmit"
},
"keywords": [
"react-native",
"async-storage",
"storage",
"api",
"core api"
],
"repository": "https://github.com/react-native-async-storage/async-storage/blob/main/packages/core",
"author": "Krzysztof Borowy <[email protected]>",
"license": "MIT",
"devDependencies": {
"eslint": "8.26.0",
"react-native-builder-bob": "0.20.0",
"typescript": "4.9.5"
},
"react-native-builder-bob": {
"source": "src",
"output": "lib",
"targets": [
"commonjs",
"module",
"typescript"
]
}
}
5 changes: 5 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function double(i: number) {
return i * i;
}

double(6);
4 changes: 4 additions & 0 deletions packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"include": ["./src/**/*"]
}
10 changes: 10 additions & 0 deletions packages/default-storage-backend/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": [
"../../.eslintrc",
"plugin:wdio/recommended"
],
"plugins": ["wdio"],
"rules": {
"dot-notation": "off"
}
}
30 changes: 2 additions & 28 deletions packages/default-storage-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@react-native-community/eslint-config": "^3.0.0",
"@semantic-release/changelog": "^6.0.0",
"@semantic-release/git": "^10.0.0",
"@types/lodash": "^4.14.184",
Expand All @@ -87,11 +86,11 @@
"appium-uiautomator2-driver": "^2.26.2",
"appium-xcuitest-driver": "^4.32.5",
"concurrently": "^6.4.0",
"eslint": "^8.0.0",
"eslint": "8.26.0",
"eslint-plugin-wdio": "^8.8.7",
"expo": "^48.0.0",
"lodash": "^4.17.21",
"prettier": "^2.5.1",
"prettier": "2.5.1",
"react": "18.2.0",
"react-dom": "^18.2.0",
"react-native": "^0.71.0",
Expand All @@ -106,31 +105,6 @@
"typescript": "^4.9.4",
"webdriverio": "^8.11.2"
},
"eslintConfig": {
"root": true,
"plugins": [
"wdio"
],
"extends": [
"@react-native-community",
"plugin:wdio/recommended"
],
"rules": {
"dot-notation": "off"
}
},
"prettier": {
"endOfLine": "auto",
"singleQuote": true,
"overrides": [
{
"files": "*.md",
"options": {
"proseWrap": "always"
}
}
]
},
"react-native-builder-bob": {
"source": "src",
"output": "lib",
Expand Down
2 changes: 2 additions & 0 deletions packages/default-storage-backend/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function checkValidInput(...input: unknown[]) {
const [key, value] = input;

if (typeof key !== 'string') {
// eslint-disable-next-line no-console
console.warn(
`[AsyncStorage] Using ${typeof key} type for key is not supported. This can lead to unexpected behavior/errors. Use string instead.\nKey passed: ${key}\n`
);
Expand All @@ -39,6 +40,7 @@ export function checkValidInput(...input: unknown[]) {
`[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`
);
} else {
// eslint-disable-next-line no-console
console.warn(
`[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`
);
Expand Down
19 changes: 1 addition & 18 deletions packages/default-storage-backend/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
{
"compilerOptions": {
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true,
"moduleResolution": "Node",
"resolveJsonModule": true,
"allowJs": true,
"checkJs": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"target": "ESNext",
"skipLibCheck": true
},
"extends": "../../tsconfig.base.json",
"include": [
"src"
]
Expand Down
21 changes: 21 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"exclude": ["node_modules"],
"compilerOptions": {
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"allowJs": true,
"checkJs": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"target": "ESNext",
"skipLibCheck": true
}
}
Loading

0 comments on commit 9f694f0

Please sign in to comment.