Skip to content

Commit 69fc7d1

Browse files
author
Krzysztof Borowy
authored
chore: Move files around, new lint rules (#1007)
* ts and eslint * clang format * contributing * bump prettier, rm config * lint result * test both repos * disable eslint quotes
1 parent 9f694f0 commit 69fc7d1

32 files changed

+130
-132
lines changed
File renamed without changes.
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"extends": ["@react-native-community"],
33
"rules": {
4-
"no-console": "error"
4+
"no-console": "error",
5+
"quotes": "off"
56
}
67
}

tsconfig.base.json renamed to .config/tsconfig.base.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
2-
"exclude": ["node_modules"],
2+
"exclude": [
3+
"../node_modules"
4+
],
35
"compilerOptions": {
46
"noFallthroughCasesInSwitch": true,
57
"noImplicitOverride": true,
File renamed without changes.

.github/workflows/ci.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ jobs:
1111
strategy:
1212
matrix:
1313
test-name: [lint, ts]
14+
workspace: [default-storage-backend, core]
1415
steps:
1516
- name: Checkout
1617
uses: actions/checkout@v3
@@ -23,7 +24,7 @@ jobs:
2324
run: yarn
2425
- name: Run test ${{ matrix.test-name }}
2526
run: yarn test:${{ matrix.test-name }}
26-
working-directory: packages/default-storage-backend
27+
working-directory: packages/${{ matrix.workspace }}
2728
android:
2829
name: Android
2930
runs-on: ubuntu-22.04

.prettierrc

-7
This file was deleted.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Head over to [documentation](https://react-native-async-storage.github.io/async-
4242
## Contribution
4343
Pull requests are welcome. Please open an issue first to discuss what you would like to change.
4444

45-
See the [CONTRIBUTING](CONTRIBUTING.md) file for more information.
45+
See the [CONTRIBUTING](.github/CONTRIBUTING.md) file for more information.
4646

4747
## License
4848

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"devDependencies": {
99
"@react-native-community/eslint-config": "3.2.0",
1010
"eslint": "8.26.0",
11-
"prettier": "2.5.1",
11+
"prettier": "2.8.8",
1212
"typescript": "4.9.5"
1313
},
1414
"resolutions": {

packages/core/.eslintrc

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

packages/core/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"extends": "../../tsconfig.base.json",
2+
"extends": "../../.config/tsconfig.base.json",
33
"include": ["./src/**/*"]
44
}

packages/default-storage-backend/.eslintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"extends": [
3-
"../../.eslintrc",
3+
"../../.config/.eslintrc",
44
"plugin:wdio/recommended"
55
],
66
"plugins": ["wdio"],
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import { config as commonConfig } from './common.conf';
1+
import { config as commonConfig } from "./common.conf";
22

33
export const config: WebdriverIO.Config = {
44
...commonConfig,
55
capabilities: [
66
{
7-
platformName: 'Android',
7+
platformName: "Android",
88
maxInstances: 1,
9-
'appium:deviceName': 'Android Emulator',
10-
'appium:app':
11-
'example/android/app/build/outputs/apk/release/app-release.apk',
12-
'appium:automationName': 'UiAutomator2',
13-
'appium:newCommandTimeout': 240,
14-
'appium:appWaitActivity':
15-
'com.microsoft.reacttestapp.component.ComponentActivity',
9+
"appium:deviceName": "Android Emulator",
10+
"appium:app":
11+
"example/android/app/build/outputs/apk/release/app-release.apk",
12+
"appium:automationName": "UiAutomator2",
13+
"appium:newCommandTimeout": 240,
14+
"appium:appWaitActivity":
15+
"com.microsoft.reacttestapp.component.ComponentActivity",
1616
},
1717
],
1818
};

packages/default-storage-backend/example/__tests__/asyncstorage.spec.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
import { commands as cmd } from './commands';
2-
import testCases from '../examples/tests';
1+
import { commands as cmd } from "./commands";
2+
import testCases from "../examples/tests";
33

4-
describe('Async Storage functional tests', () => {
5-
it('should be visible', async () => {
4+
describe("Async Storage functional tests", () => {
5+
it("should be visible", async () => {
66
// wait until content loads, as android's waitForSelectorTimeout setting does not seem to work
77
await new Promise((r) => setTimeout(r, 3000));
8-
const el = await cmd.elementByLabel('functional-view');
8+
const el = await cmd.elementByLabel("functional-view");
99
await expect(await el.isExisting()).toEqual(true);
1010
});
1111

1212
const testNames = Object.keys(testCases);
13-
describe('storing / reading values', () => {
13+
describe("storing / reading values", () => {
1414
for (const name of testNames) {
1515
it(name, async () => {
1616
const el = await cmd.elementByLabel(`test:${name}`);
17-
await expect(await el.getText()).toEqual('Pass');
17+
await expect(await el.getText()).toEqual("Pass");
1818
});
1919
}
2020
});
2121

22-
describe('storing / reading values with delegate', () => {
22+
describe("storing / reading values with delegate", () => {
2323
for (const currentName of testNames) {
24-
const name = currentName + ' with delegate';
24+
const name = currentName + " with delegate";
2525
it(name, async () => {
2626
const el = await cmd.elementByLabel(`test:${name}`);
2727
const label = await el.getText();
28-
if (label === 'Skip') {
28+
if (label === "Skip") {
2929
return;
3030
}
3131

32-
expect(label).toEqual('Pass');
32+
expect(label).toEqual("Pass");
3333
});
3434
}
3535
});

packages/default-storage-backend/example/__tests__/commands.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const testAppId = 'com.microsoft.ReactTestApp';
2-
import { browser } from '@wdio/globals';
1+
const testAppId = "com.microsoft.ReactTestApp";
2+
import { browser } from "@wdio/globals";
33

44
export const commands = {
55
restartApp: async () => {

packages/default-storage-backend/example/__tests__/common.conf.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
export const config: WebdriverIO.Config = {
2-
runner: 'local',
2+
runner: "local",
33
autoCompileOpts: {
44
autoCompile: true,
55
tsNodeOpts: {
66
transpileOnly: true,
7-
project: '../../tsconfig.all.json',
7+
project: "../../tsconfig.all.json",
88
},
99
},
1010
capabilities: [],
1111
connectionRetryTimeout: 180000,
1212
waitforTimeout: 90000,
13-
framework: 'mocha',
14-
reporters: ['spec'],
13+
framework: "mocha",
14+
reporters: ["spec"],
1515
mochaOpts: {
16-
ui: 'bdd',
16+
ui: "bdd",
1717
/**
1818
* NOTE: This has been increased for more stable Appium Native app
1919
* tests because they can take a bit longer.
2020
*/
2121
timeout: 5 * 60 * 1000, // 5min
2222
},
23-
specs: ['./asyncstorage.spec.ts'],
23+
specs: ["./asyncstorage.spec.ts"],
2424
services: [
2525
[
26-
'appium',
26+
"appium",
2727
{
28-
command: 'appium',
28+
command: "appium",
2929
args: {
3030
// This is needed to tell Appium that we can execute local ADB commands
3131
// and to automatically download the latest version of ChromeDriver
3232
relaxedSecurity: true,
33-
address: '127.0.0.1',
34-
'callback-port': 4723,
33+
address: "127.0.0.1",
34+
"callback-port": 4723,
3535
port: 4723,
3636
},
3737
},
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import { config as commonConfig } from './common.conf';
1+
import { config as commonConfig } from "./common.conf";
22

33
export const config: WebdriverIO.Config = {
44
...commonConfig,
55
capabilities: [
66
{
7-
platformName: 'iOS',
8-
'appium:platformVersion': '16.4',
9-
'appium:deviceName': 'iPhone 14',
10-
'appium:automationName': 'XCUITest',
11-
'appium:app':
12-
'example/ios/build/Build/Products/Release-iphonesimulator/ReactTestApp.app',
7+
platformName: "iOS",
8+
"appium:platformVersion": "16.4",
9+
"appium:deviceName": "iPhone 14",
10+
"appium:automationName": "XCUITest",
11+
"appium:app":
12+
"example/ios/build/Build/Products/Release-iphonesimulator/ReactTestApp.app",
1313
},
1414
],
1515
};

packages/default-storage-backend/example/examples/tests.ts

+24-24
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,47 @@ export type TestValue = string | Record<string, string>;
22

33
export type TestStep =
44
| {
5-
command: 'merge' | 'set';
5+
command: "merge" | "set";
66
key: string;
77
value: TestValue;
88
expected?: TestValue | null;
99
}
1010
| {
11-
command: 'remove';
11+
command: "remove";
1212
key: string;
1313
};
1414

1515
const tests: Record<string, TestStep[]> = {
16-
'Should store value in AsyncStorage': [
17-
{ command: 'set', key: 'a', value: '0' },
18-
{ command: 'set', key: 'a', value: '10' },
19-
{ command: 'set', key: 'a', value: '20' },
20-
{ command: 'set', key: 'a', value: '30' },
21-
{ command: 'set', key: 'a', value: '40' },
16+
"Should store value in AsyncStorage": [
17+
{ command: "set", key: "a", value: "0" },
18+
{ command: "set", key: "a", value: "10" },
19+
{ command: "set", key: "a", value: "20" },
20+
{ command: "set", key: "a", value: "30" },
21+
{ command: "set", key: "a", value: "40" },
2222
],
23-
'Should clear item': [
24-
{ command: 'set', key: 'a', value: '42' },
25-
{ command: 'remove', key: 'a' },
23+
"Should clear item": [
24+
{ command: "set", key: "a", value: "42" },
25+
{ command: "remove", key: "a" },
2626
],
27-
'Should merge items': [
27+
"Should merge items": [
2828
{
29-
command: 'set',
30-
key: 'a',
29+
command: "set",
30+
key: "a",
3131
value: {
32-
name: 'Jerry',
33-
age: '21',
34-
eyesColor: 'blue',
35-
shoeSize: '9',
32+
name: "Jerry",
33+
age: "21",
34+
eyesColor: "blue",
35+
shoeSize: "9",
3636
},
3737
},
3838
{
39-
command: 'merge',
40-
key: 'a',
39+
command: "merge",
40+
key: "a",
4141
value: {
42-
name: 'Sarah',
43-
age: '23',
44-
eyesColor: 'green',
45-
shoeSize: '10',
42+
name: "Sarah",
43+
age: "23",
44+
eyesColor: "green",
45+
shoeSize: "10",
4646
},
4747
},
4848
],

packages/default-storage-backend/example/index.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import { AppRegistry, Platform } from 'react-native';
9-
import App from './App';
10-
import { name as appName } from './app.json';
8+
import { AppRegistry, Platform } from "react-native";
9+
import App from "./App";
10+
import { name as appName } from "./app.json";
1111

1212
AppRegistry.registerComponent(appName, () => App);
1313

14-
if (Platform.OS === 'web') {
15-
const rootTag = document.getElementById('root');
14+
if (Platform.OS === "web") {
15+
const rootTag = document.getElementById("root");
1616
AppRegistry.runApplication(appName, { rootTag });
1717
}

packages/default-storage-backend/ios/RNCAsyncStorage.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@
2929
*/
3030
@interface RNCAsyncStorage : NSObject <
3131
#ifdef RCT_NEW_ARCH_ENABLED
32-
NativeAsyncStorageModuleSpec
32+
NativeAsyncStorageModuleSpec
3333
#else
34-
RCTBridgeModule
34+
RCTBridgeModule
3535
#endif
36-
, RCTInvalidating>
36+
,
37+
RCTInvalidating>
3738

3839
@property (nonatomic, weak, nullable) id<RNCAsyncStorageDelegate> delegate;
3940

packages/default-storage-backend/ios/RNCAsyncStorage.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ - (BOOL)_passthroughDelegate
899899
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
900900
(const facebook::react::ObjCTurboModule::InitParams &)params
901901
{
902-
return std::make_shared<facebook::react::NativeAsyncStorageModuleSpecJSI>(params);
902+
return std::make_shared<facebook::react::NativeAsyncStorageModuleSpecJSI>(params);
903903
}
904904
#endif
905905

packages/default-storage-backend/jest/async-storage-mock.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable no-undef */
22

3-
const merge = require('merge-options').bind({
3+
const merge = require("merge-options").bind({
44
concatArrays: true,
55
ignoreUndefined: true,
66
});

packages/default-storage-backend/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
},
3939
"scripts": {
4040
"format": "concurrently yarn:format:*",
41-
"format:c": "clang-format -i $(git ls-files '*.cpp' '*.h' '*.m' '*.mm')",
41+
"format:c": "clang-format -i $(git ls-files '*.cpp' '*.h' '*.m' '*.mm') --style file:../../.config/.clang-format",
4242
"format:js": "prettier --write $(git ls-files '*.js' '*.json' '*.md' '*.ts' '*.tsx' '*.yml')",
4343
"prepare": "bob build",
4444
"start": "react-native start",
@@ -90,7 +90,7 @@
9090
"eslint-plugin-wdio": "^8.8.7",
9191
"expo": "^48.0.0",
9292
"lodash": "^4.17.21",
93-
"prettier": "2.5.1",
93+
"prettier": "2.8.8",
9494
"react": "18.2.0",
9595
"react-dom": "^18.2.0",
9696
"react-native": "^0.71.0",

packages/default-storage-backend/src/AsyncStorage.native.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ import {
1010
checkValidInput,
1111
convertError,
1212
convertErrors,
13-
} from './helpers';
14-
import RCTAsyncStorage from './RCTAsyncStorage';
13+
} from "./helpers";
14+
import RCTAsyncStorage from "./RCTAsyncStorage";
1515
import type {
1616
AsyncStorageStatic,
1717
ErrorLike,
1818
KeyValuePair,
1919
MultiRequest,
20-
} from './types';
20+
} from "./types";
2121

2222
if (!RCTAsyncStorage) {
2323
throw new Error(`[@RNC/AsyncStorage]: NativeModule: AsyncStorage is null.

0 commit comments

Comments
 (0)