Skip to content

Commit

Permalink
chore: Move files around, new lint rules (react-native-async-storage#…
Browse files Browse the repository at this point in the history
…1007)

* ts and eslint

* clang format

* contributing

* bump prettier, rm config

* lint result

* test both repos

* disable eslint quotes
  • Loading branch information
Krzysztof Borowy authored Sep 1, 2023
1 parent 9f694f0 commit 69fc7d1
Show file tree
Hide file tree
Showing 32 changed files with 130 additions and 132 deletions.
File renamed without changes.
3 changes: 2 additions & 1 deletion .eslintrc → .config/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": ["@react-native-community"],
"rules": {
"no-console": "error"
"no-console": "error",
"quotes": "off"
}
}
4 changes: 3 additions & 1 deletion tsconfig.base.json → .config/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"exclude": ["node_modules"],
"exclude": [
"../node_modules"
],
"compilerOptions": {
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
strategy:
matrix:
test-name: [lint, ts]
workspace: [default-storage-backend, core]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -23,7 +24,7 @@ jobs:
run: yarn
- name: Run test ${{ matrix.test-name }}
run: yarn test:${{ matrix.test-name }}
working-directory: packages/default-storage-backend
working-directory: packages/${{ matrix.workspace }}
android:
name: Android
runs-on: ubuntu-22.04
Expand Down
7 changes: 0 additions & 7 deletions .prettierrc

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Head over to [documentation](https://react-native-async-storage.github.io/async-
## Contribution
Pull requests are welcome. Please open an issue first to discuss what you would like to change.

See the [CONTRIBUTING](CONTRIBUTING.md) file for more information.
See the [CONTRIBUTING](.github/CONTRIBUTING.md) file for more information.

## License

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"devDependencies": {
"@react-native-community/eslint-config": "3.2.0",
"eslint": "8.26.0",
"prettier": "2.5.1",
"prettier": "2.8.8",
"typescript": "4.9.5"
},
"resolutions": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "../../.eslintrc"
"extends": "../../.config/.eslintrc"
}
2 changes: 1 addition & 1 deletion packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../.config/tsconfig.base.json",
"include": ["./src/**/*"]
}
2 changes: 1 addition & 1 deletion packages/default-storage-backend/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": [
"../../.eslintrc",
"../../.config/.eslintrc",
"plugin:wdio/recommended"
],
"plugins": ["wdio"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { config as commonConfig } from './common.conf';
import { config as commonConfig } from "./common.conf";

export const config: WebdriverIO.Config = {
...commonConfig,
capabilities: [
{
platformName: 'Android',
platformName: "Android",
maxInstances: 1,
'appium:deviceName': 'Android Emulator',
'appium:app':
'example/android/app/build/outputs/apk/release/app-release.apk',
'appium:automationName': 'UiAutomator2',
'appium:newCommandTimeout': 240,
'appium:appWaitActivity':
'com.microsoft.reacttestapp.component.ComponentActivity',
"appium:deviceName": "Android Emulator",
"appium:app":
"example/android/app/build/outputs/apk/release/app-release.apk",
"appium:automationName": "UiAutomator2",
"appium:newCommandTimeout": 240,
"appium:appWaitActivity":
"com.microsoft.reacttestapp.component.ComponentActivity",
},
],
};
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
import { commands as cmd } from './commands';
import testCases from '../examples/tests';
import { commands as cmd } from "./commands";
import testCases from "../examples/tests";

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

const testNames = Object.keys(testCases);
describe('storing / reading values', () => {
describe("storing / reading values", () => {
for (const name of testNames) {
it(name, async () => {
const el = await cmd.elementByLabel(`test:${name}`);
await expect(await el.getText()).toEqual('Pass');
await expect(await el.getText()).toEqual("Pass");
});
}
});

describe('storing / reading values with delegate', () => {
describe("storing / reading values with delegate", () => {
for (const currentName of testNames) {
const name = currentName + ' with delegate';
const name = currentName + " with delegate";
it(name, async () => {
const el = await cmd.elementByLabel(`test:${name}`);
const label = await el.getText();
if (label === 'Skip') {
if (label === "Skip") {
return;
}

expect(label).toEqual('Pass');
expect(label).toEqual("Pass");
});
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const testAppId = 'com.microsoft.ReactTestApp';
import { browser } from '@wdio/globals';
const testAppId = "com.microsoft.ReactTestApp";
import { browser } from "@wdio/globals";

export const commands = {
restartApp: async () => {
Expand Down
20 changes: 10 additions & 10 deletions packages/default-storage-backend/example/__tests__/common.conf.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
export const config: WebdriverIO.Config = {
runner: 'local',
runner: "local",
autoCompileOpts: {
autoCompile: true,
tsNodeOpts: {
transpileOnly: true,
project: '../../tsconfig.all.json',
project: "../../tsconfig.all.json",
},
},
capabilities: [],
connectionRetryTimeout: 180000,
waitforTimeout: 90000,
framework: 'mocha',
reporters: ['spec'],
framework: "mocha",
reporters: ["spec"],
mochaOpts: {
ui: 'bdd',
ui: "bdd",
/**
* NOTE: This has been increased for more stable Appium Native app
* tests because they can take a bit longer.
*/
timeout: 5 * 60 * 1000, // 5min
},
specs: ['./asyncstorage.spec.ts'],
specs: ["./asyncstorage.spec.ts"],
services: [
[
'appium',
"appium",
{
command: 'appium',
command: "appium",
args: {
// This is needed to tell Appium that we can execute local ADB commands
// and to automatically download the latest version of ChromeDriver
relaxedSecurity: true,
address: '127.0.0.1',
'callback-port': 4723,
address: "127.0.0.1",
"callback-port": 4723,
port: 4723,
},
},
Expand Down
14 changes: 7 additions & 7 deletions packages/default-storage-backend/example/__tests__/ios.conf.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { config as commonConfig } from './common.conf';
import { config as commonConfig } from "./common.conf";

export const config: WebdriverIO.Config = {
...commonConfig,
capabilities: [
{
platformName: 'iOS',
'appium:platformVersion': '16.4',
'appium:deviceName': 'iPhone 14',
'appium:automationName': 'XCUITest',
'appium:app':
'example/ios/build/Build/Products/Release-iphonesimulator/ReactTestApp.app',
platformName: "iOS",
"appium:platformVersion": "16.4",
"appium:deviceName": "iPhone 14",
"appium:automationName": "XCUITest",
"appium:app":
"example/ios/build/Build/Products/Release-iphonesimulator/ReactTestApp.app",
},
],
};
48 changes: 24 additions & 24 deletions packages/default-storage-backend/example/examples/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,47 @@ export type TestValue = string | Record<string, string>;

export type TestStep =
| {
command: 'merge' | 'set';
command: "merge" | "set";
key: string;
value: TestValue;
expected?: TestValue | null;
}
| {
command: 'remove';
command: "remove";
key: string;
};

const tests: Record<string, TestStep[]> = {
'Should store value in AsyncStorage': [
{ command: 'set', key: 'a', value: '0' },
{ command: 'set', key: 'a', value: '10' },
{ command: 'set', key: 'a', value: '20' },
{ command: 'set', key: 'a', value: '30' },
{ command: 'set', key: 'a', value: '40' },
"Should store value in AsyncStorage": [
{ command: "set", key: "a", value: "0" },
{ command: "set", key: "a", value: "10" },
{ command: "set", key: "a", value: "20" },
{ command: "set", key: "a", value: "30" },
{ command: "set", key: "a", value: "40" },
],
'Should clear item': [
{ command: 'set', key: 'a', value: '42' },
{ command: 'remove', key: 'a' },
"Should clear item": [
{ command: "set", key: "a", value: "42" },
{ command: "remove", key: "a" },
],
'Should merge items': [
"Should merge items": [
{
command: 'set',
key: 'a',
command: "set",
key: "a",
value: {
name: 'Jerry',
age: '21',
eyesColor: 'blue',
shoeSize: '9',
name: "Jerry",
age: "21",
eyesColor: "blue",
shoeSize: "9",
},
},
{
command: 'merge',
key: 'a',
command: "merge",
key: "a",
value: {
name: 'Sarah',
age: '23',
eyesColor: 'green',
shoeSize: '10',
name: "Sarah",
age: "23",
eyesColor: "green",
shoeSize: "10",
},
},
],
Expand Down
10 changes: 5 additions & 5 deletions packages/default-storage-backend/example/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
* LICENSE file in the root directory of this source tree.
*/

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

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

if (Platform.OS === 'web') {
const rootTag = document.getElementById('root');
if (Platform.OS === "web") {
const rootTag = document.getElementById("root");
AppRegistry.runApplication(appName, { rootTag });
}
7 changes: 4 additions & 3 deletions packages/default-storage-backend/ios/RNCAsyncStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@
*/
@interface RNCAsyncStorage : NSObject <
#ifdef RCT_NEW_ARCH_ENABLED
NativeAsyncStorageModuleSpec
NativeAsyncStorageModuleSpec
#else
RCTBridgeModule
RCTBridgeModule
#endif
, RCTInvalidating>
,
RCTInvalidating>

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

Expand Down
2 changes: 1 addition & 1 deletion packages/default-storage-backend/ios/RNCAsyncStorage.mm
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ - (BOOL)_passthroughDelegate
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
(const facebook::react::ObjCTurboModule::InitParams &)params
{
return std::make_shared<facebook::react::NativeAsyncStorageModuleSpecJSI>(params);
return std::make_shared<facebook::react::NativeAsyncStorageModuleSpecJSI>(params);
}
#endif

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-undef */

const merge = require('merge-options').bind({
const merge = require("merge-options").bind({
concatArrays: true,
ignoreUndefined: true,
});
Expand Down
4 changes: 2 additions & 2 deletions packages/default-storage-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
"scripts": {
"format": "concurrently yarn:format:*",
"format:c": "clang-format -i $(git ls-files '*.cpp' '*.h' '*.m' '*.mm')",
"format:c": "clang-format -i $(git ls-files '*.cpp' '*.h' '*.m' '*.mm') --style file:../../.config/.clang-format",
"format:js": "prettier --write $(git ls-files '*.js' '*.json' '*.md' '*.ts' '*.tsx' '*.yml')",
"prepare": "bob build",
"start": "react-native start",
Expand Down Expand Up @@ -90,7 +90,7 @@
"eslint-plugin-wdio": "^8.8.7",
"expo": "^48.0.0",
"lodash": "^4.17.21",
"prettier": "2.5.1",
"prettier": "2.8.8",
"react": "18.2.0",
"react-dom": "^18.2.0",
"react-native": "^0.71.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/default-storage-backend/src/AsyncStorage.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import {
checkValidInput,
convertError,
convertErrors,
} from './helpers';
import RCTAsyncStorage from './RCTAsyncStorage';
} from "./helpers";
import RCTAsyncStorage from "./RCTAsyncStorage";
import type {
AsyncStorageStatic,
ErrorLike,
KeyValuePair,
MultiRequest,
} from './types';
} from "./types";

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

0 comments on commit 69fc7d1

Please sign in to comment.