diff --git a/.circleci/config.yml b/.circleci/config.yml index 9b166f2a..480b056e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,7 +26,6 @@ default config for macOS: &macos_defaults macos: xcode: '12.5.1' - config for macOS (android): &macos_defaults_android <<: *defaults resource_class: 'medium' @@ -143,13 +142,13 @@ jobs: name: Lint check command: yarn test:lint - "Test: flow": + "Test: TypeScript": <<: *js_defaults steps: - *addWorkspace - run: - name: Flow check - command: yarn test:flow + name: TypeScript check + command: yarn test:ts "Test: Android unit": <<: *android_defaults @@ -322,7 +321,7 @@ workflows: - "Test: lint": requires: - "Setup environment" - - "Test: flow": + - "Test: TypeScript": requires: - "Setup environment" - "Test: Android unit": @@ -331,11 +330,11 @@ workflows: - "Test: iOS e2e": requires: - "Test: lint" - - "Test: flow" + - "Test: TypeScript" - "Build: Android release apk": requires: - "Test: lint" - - "Test: flow" + - "Test: TypeScript" - "Test: Android unit" - "Test: Android e2e": requires: diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index e1f57cfa..00000000 --- a/.eslintrc +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "@react-native-community", - "globals": { - "it": true, - "expect": true, - "element": true, - "describe": true, - "xdescribe": true, - "by": true, - "device": true, - "beforeAll": true, - "beforeEach": true, - "afterAll": true, - "jest": true, - "jasmine": true - } -} diff --git a/.flowconfig b/.flowconfig deleted file mode 100644 index ea05428e..00000000 --- a/.flowconfig +++ /dev/null @@ -1,75 +0,0 @@ -[ignore] -; Build output -/lib/ - -; We fork some components by platform -.*/*[.]android.js - -; Ignore "BUCK" generated dirs -/\.buckd/ - -; Ignore polyfills -node_modules/react-native/Libraries/polyfills/.* - -; Flow doesn't support platforms -.*/Libraries/Utilities/LoadingView.js - -; Ignore tests -.*/test/.* - -[untyped] -.*/node_modules/@react-native-community/cli/.*/.* - -[include] - -[libs] -node_modules/react-native/interface.js -node_modules/react-native/flow/ - -[options] -emoji=true - -esproposal.optional_chaining=enable -esproposal.nullish_coalescing=enable - -module.file_ext=.js -module.file_ext=.json -module.file_ext=.ios.js - -munge_underscores=true - -server.max_workers=1 - -# Support the library import in examples -module.name_mapper='^\@react-native-async-storage/async-storage$' -> '/src/AsyncStorage.js' - -module.name_mapper='^react-native/\(.*\)$' -> '/node_modules/react-native/\1' -module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '/node_modules/react-native/Libraries/Image/RelativeImageStub' - -suppress_type=$FlowIssue -suppress_type=$FlowFixMe -suppress_type=$FlowFixMeProps -suppress_type=$FlowFixMeState - -[lints] -sketchy-null-number=warn -sketchy-null-mixed=warn -sketchy-number=warn -untyped-type-import=warn -nonstrict-import=warn -deprecated-type=warn -unsafe-getters-setters=warn -unnecessary-invariant=warn -signature-verification-failure=warn - -[strict] -deprecated-type -nonstrict-import -sketchy-null -unclear-type -unsafe-getters-setters -untyped-import -untyped-type-import - -[version] -^0.137.0 diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index f71501cb..5ad9dfb6 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -21,14 +21,14 @@ body: attributes: label: Version description: What version of `@react-native-async-storage/async-storage` are you using? - placeholder: "Example: 1.15.9" + placeholder: 'Example: 1.15.9' validations: required: true - type: checkboxes id: platforms attributes: label: What platforms are you seeing this issue on? - description: "Select all that apply:" + description: 'Select all that apply:' options: - label: Android - label: iOS diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8f0a0767..764a6715 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ on: pull_request: jobs: macos: - name: "macOS" + name: 'macOS' runs-on: macos-latest steps: - name: Set up Node.js @@ -34,7 +34,7 @@ jobs: run: | yarn test:e2e:macos windows: - name: "Windows" + name: 'Windows' runs-on: windows-latest steps: - name: Set up MSBuild diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 86d807b2..fe258d6b 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -1,7 +1,7 @@ name: Mark stale issues and pull requests on: schedule: - - cron: "30 1 * * *" + - cron: '30 1 * * *' jobs: stale: runs-on: ubuntu-latest @@ -9,10 +9,10 @@ jobs: issues: write pull-requests: write steps: - - uses: actions/stale@v4 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-issue-message: 'This issue has been marked as stale due to inactivity. Please respond or otherwise resolve the issue within 7 days or it will be closed.' - stale-pr-message: 'This PR has been marked as stale due to inactivity. Please address any comments within 7 days or it will be closed.' - exempt-issue-labels: 'help wanted :octocat:' - exempt-pr-labels: 'WIP' + - uses: actions/stale@v4 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-issue-message: 'This issue has been marked as stale due to inactivity. Please respond or otherwise resolve the issue within 7 days or it will be closed.' + stale-pr-message: 'This PR has been marked as stale due to inactivity. Please address any comments within 7 days or it will be closed.' + exempt-issue-labels: 'help wanted :octocat:' + exempt-pr-labels: 'WIP' diff --git a/.github/workflows/website-deployment.yml b/.github/workflows/website-deployment.yml index 69503fa0..62921cd3 100644 --- a/.github/workflows/website-deployment.yml +++ b/.github/workflows/website-deployment.yml @@ -2,9 +2,9 @@ name: Website Deployment on: push: branches: - - master + - master paths: - - 'website/**' + - 'website/**' jobs: deploy: @@ -12,23 +12,20 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Cache/restore dependencies - uses: actions/cache@v1 - id: cache - with: - path: ./website/node_modules - key: website-${{ hashFiles('website/yarn.lock') }} - - name: Install dependencies - if: steps.cache.outputs.cache-hit != 'true' - run: yarn install --frozen-lockfile --cwd ./website - - name: Release - working-directory: ./website - run: | - git config --global user.name ${{ secrets.GH_DEPLOY_NAME }} - git config --global user.email ${{ secrets.GH_DEPLOY_EMAIL }} - echo "machine github.com login ${{ secrets.GH_DEPLOY_NAME }} password ${{ secrets.GH_DEPLOY_TOKEN }}" > ~/.netrc - GIT_USER=${{ secrets.GH_DEPLOY_NAME }} yarn run deploy - - - + - uses: actions/checkout@v2 + - name: Cache/restore dependencies + uses: actions/cache@v1 + id: cache + with: + path: ./website/node_modules + key: website-${{ hashFiles('website/yarn.lock') }} + - name: Install dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: yarn install --frozen-lockfile --cwd ./website + - name: Release + working-directory: ./website + run: | + git config --global user.name ${{ secrets.GH_DEPLOY_NAME }} + git config --global user.email ${{ secrets.GH_DEPLOY_EMAIL }} + echo "machine github.com login ${{ secrets.GH_DEPLOY_NAME }} password ${{ secrets.GH_DEPLOY_TOKEN }}" > ~/.netrc + GIT_USER=${{ secrets.GH_DEPLOY_NAME }} yarn run deploy diff --git a/.npmignore b/.npmignore index 0f8d8c1b..2eaef62d 100644 --- a/.npmignore +++ b/.npmignore @@ -10,7 +10,6 @@ README.md babel.config.js .clang-format .eslintrc -.flowconfig .watchmanconfig .npmrc .circleci diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 1d4c3eff..00000000 --- a/.prettierrc +++ /dev/null @@ -1,8 +0,0 @@ -{ - "requirePragma": true, - "singleQuote": true, - "trailingComma": "all", - "bracketSpacing": false, - "jsxBracketSameLine": true, - "parser": "flow" -} \ No newline at end of file diff --git a/.releaserc b/.releaserc deleted file mode 100644 index fccef6cc..00000000 --- a/.releaserc +++ /dev/null @@ -1,19 +0,0 @@ -{ - "branches": [ - "master" - ], - "plugins": [ - "@semantic-release/commit-analyzer", - "@semantic-release/release-notes-generator", - "@semantic-release/changelog", - "@semantic-release/npm", - "@semantic-release/github", - [ - "@semantic-release/git", - { - "assets": ["CHANGELOG.md", "package.json"], - "message": "chore(release): ${nextRelease.version} [skip ci]" - } - ] - ] -} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 42fab25a..f629ac94 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,55 +1,82 @@ # Contributing to React Native Async Storage -Thank you for helping out with Async Storage! -We'd like to make contributions as pleasent as possible, so here's a small guide of how we see it. Happy to hear your feedback about anything, so please let us know. - +Thank you for helping out with Async Storage! We'd like to make contributions as +pleasent as possible, so here's a small guide of how we see it. Happy to hear +your feedback about anything, so please let us know. ## Tests -We use `flow` for type check, `eslint` with `prettier` for linting/formatting, `jest/detox` for tests (unit and e2e). All tests are run on CircleCI for all opened pull requests, but you should use them locally when making changes. -* `yarn test`: Run all tests, except for e2e (see note below). -* `yarn test:lint`: Run `eslint` check. -* `yarn test:flow`: Run `flow` type check. -* `yarn test:e2e:`: Runs e2e tests. Before you can run it, you should build the app that can be run, by using `yarn build:e2e:`. +We use TypeScript for type check, `eslint` with `prettier` for +linting/formatting, `jest/detox` for tests (unit and e2e). All tests are run on +CircleCI for all opened pull requests, but you should use them locally when +making changes. +- `yarn test`: Run all tests, except for e2e (see note below). +- `yarn test:lint`: Run `eslint` check. +- `yarn test:ts`: Run `tsc` type check. +- `yarn test:e2e:`: Runs e2e tests. Before you can run it, + you should build the app that can be run, by using + `yarn build:e2e:`. ## Sending a pull request -When you're sending a pull request: -* Communication is a key. If you want fix/add something, please open new/find existing issue, so we can discuss it. -* We prefer small pull requests focused on one change, as those are easier to test/check. -* Please make sure that all tests are passing on your local machine. -* Please make sure you've run formatters and linters locally. - * In VS Code, you can press ⇧+Alt+F or ⇧⌥F to format the current file. - * To format C++ and Objective-C files, make sure you have the [C/C++ extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) installed. - * To format JavaScript files, please install [Prettier extension](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode). - * From the command line, you can run `yarn format:c` and `yarn format:js` to format C-based languages and JavaScript respectively. The first command requires that you've already installed [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html). -* Follow the template when opening a PR. +When you're sending a pull request: +- Communication is a key. If you want fix/add something, please open new/find + existing issue, so we can discuss it. +- We prefer small pull requests focused on one change, as those are easier to + test/check. +- Please make sure that all tests are passing on your local machine. +- Please make sure you've run formatters and linters locally. + - In VS Code, you can press ⇧+Alt+F or ⇧⌥F to format the current file. + - To format C++ and Objective-C files, make sure you have the + [C/C++ extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) + installed. + - To format JavaScript files, please install + [Prettier extension](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode). + - From the command line, you can run `yarn format:c` and `yarn format:js` to + format C-based languages and JavaScript respectively. The first command + requires that you've already installed + [ClangFormat](https://clang.llvm.org/docs/ClangFormat.html). +- Follow the template when opening a PR. ## Commits and versioning -All PRs are squashed into `master` branch and wrapped up in a single commit, following [conventional commit message](https://www.conventionalcommits.org/en/v1.0.0-beta.3). Combined with [semantic versioning](https://semver.org/), this allows us to have a frequent releases of the library. -*Note*: We don't force this convention on Pull Requests from contributors, but it's a clean way to see what type of changes are made, so feel free to follow it. +All PRs are squashed into `master` branch and wrapped up in a single commit, +following +[conventional commit message](https://www.conventionalcommits.org/en/v1.0.0-beta.3). +Combined with [semantic versioning](https://semver.org/), this allows us to have +a frequent releases of the library. +_Note_: We don't force this convention on Pull Requests from contributors, but +it's a clean way to see what type of changes are made, so feel free to follow +it. Most notably prefixes you'll see: -* **fix**: Bug fixes, triggers *patch* release -* **feat**: New feature implemented, triggers *minor* -* **chore**: Changes that are not affecting end user (CI config changes, scripts, ["grunt work"](https://stackoverflow.com/a/26944812/3510245)) -* **docs**: Documentation changes. -* **perf**: A code change that improves performance. -* **refactor**: A code change that neither fixes a bug nor adds a feature. -* **test**: Adding missing tests or correcting existing tests. - +- **fix**: Bug fixes, triggers _patch_ release +- **feat**: New feature implemented, triggers _minor_ +- **chore**: Changes that are not affecting end user (CI config changes, + scripts, ["grunt work"](https://stackoverflow.com/a/26944812/3510245)) +- **docs**: Documentation changes. +- **perf**: A code change that improves performance. +- **refactor**: A code change that neither fixes a bug nor adds a feature. +- **test**: Adding missing tests or correcting existing tests. ## Release process -We use [Semantic Release](http://semantic-release.org) to automatically release new versions of the library when changes are merged into `master` branch, which we plan to keep stable. Bug fixes take priority in the release order. + +We use [Semantic Release](http://semantic-release.org) to automatically release +new versions of the library when changes are merged into `master` branch, which +we plan to keep stable. Bug fixes take priority in the release order. ## Reporting issues -You can report issues on our [bug tracker](https://github.com/react-native-community/react-native-async-storage/issues). Please search for existing issues and follow the issue template when opening an one. +You can report issues on our +[bug tracker](https://github.com/react-native-community/react-native-async-storage/issues). +Please search for existing issues and follow the issue template when opening an +one. ## License -By contributing to React Native Async Storage, you agree that your contributions will be licensed under the **MIT** license. + +By contributing to React Native Async Storage, you agree that your contributions +will be licensed under the **MIT** license. diff --git a/example/App.tsx b/example/App.tsx index 84a3c060..6ea3b65a 100644 --- a/example/App.tsx +++ b/example/App.tsx @@ -13,7 +13,7 @@ import { StyleSheet, Text, TouchableOpacity, - View + View, } from 'react-native'; import BasicExample from './examples/Basic'; import GetSetClear from './examples/GetSetClear'; @@ -51,9 +51,15 @@ export default function App(): JSX.Element { const [currentTest, setCurrentTest] = useState(TESTS.GetSetClear); const dismissKeyboard = useCallback(() => Keyboard.dismiss(), []); - const simulateRestart = useCallback(() => setIteration(iteration + 1), [iteration]); + const simulateRestart = useCallback( + () => setIteration(iteration + 1), + [iteration] + ); const testBasic = useCallback(() => setCurrentTest(TESTS.Basic), []); - const testGetSetClear = useCallback(() => setCurrentTest(TESTS.GetSetClear), []); + const testGetSetClear = useCallback( + () => setCurrentTest(TESTS.GetSetClear), + [] + ); const testMergeItem = useCallback(() => setCurrentTest(TESTS.MergeItem), []); return ( @@ -68,7 +74,8 @@ export default function App(): JSX.Element { testID="restart_button" onPress={simulateRestart} style={styles.restartButton} - activeOpacity={0.6}> + activeOpacity={0.6} + > Simulate Restart @@ -83,23 +90,17 @@ export default function App(): JSX.Element { title="Merge Item" onPress={testMergeItem} /> -