Skip to content

Latest commit

 

History

History
153 lines (102 loc) · 5.76 KB

CONTRIBUTING.md

File metadata and controls

153 lines (102 loc) · 5.76 KB

Contributing

This library is a community effort: it can only be great if we all help out in one way or another! If you feel like you aren't experienced enough using React Navigation to contribute, you can still make an impact by:

  • Responding to one of the open issues. Even if you can't resolve or fully answer a question, asking for more information or clarity on an issue is extremely beneficial for someone to come after you to resolve the issue.
  • Creating public example repositories or Snacks of navigation problems you have solved and sharing the links.
  • Answering questions on Stack Overflow.
  • Answering questions in our Reactiflux channel.
  • Providing feedback on the open PRs.
  • Providing feedback on the open RFCs.
  • Improving the website.

If you don't know where to start, check the ones with the label good first issue - even fixing a typo in the documentation is a worthy contribution!

Development workflow

The project uses a monorepo structure for the packages managed by yarn workspaces and lerna. To get started with the project, run yarn in the root directory to install the required dependencies for each package:

yarn

While developing, you can run the example app with Expo to test your changes:

yarn example start

Make sure your code passes TypeScript and ESLint. Run the following to verify:

yarn typecheck
yarn lint

To fix formatting errors, run the following:

yarn lint --fix

Remember to add tests for your change if possible. Run the unit tests by:

yarn test

Before running tests configure Playwright with:

npx playwright install

Run the e2e tests by:

yarn example e2e:web --ui

By default, this will use the local dev server for the app. If you want to test a production build, first build the example app for web:

yarn example expo export --platform web

Then run the tests with the CI environment variable:

CI=1 yarn example e2e:web

Before running Maestro tests:

  • Install it following the instructions here.
  • Start the Emulator or Simulator and install the Expo Go app.
  • Start the Metro server with yarn example start.

Then run the Maestro tests by:

yarn example e2e:native

Commit message convention

We follow the conventional commits specification for our commit messages:

  • fix: bug fixes, e.g. fix crash due to deprecated method.
  • feat: new features, e.g. add new method to the module.
  • refactor: code refactor, e.g. migrate from class components to hooks.
  • docs: changes to documentation, e.g. add usage example for the module.
  • test: adding or updating tests, eg add e2e tests using maestro.
  • chore: tooling changes, e.g. change CI config.

Our pre-commit hooks verify that your commit message matches this format when committing.

Linting and tests

ESLint, Prettier, TypeScript

We use TypeScript for type checking, ESLint with Prettier for linting and formatting the code, and Jest for testing.

Our pre-commit hooks verify that the linter and tests pass when committing.

Scripts

The package.json file contains various scripts for common tasks:

  • yarn install: setup project by installing all dependencies and pods.
  • yarn typecheck: type-check files with TypeScript.
  • yarn lint: lint files with ESLint.
  • yarn test: run unit tests with Jest.
  • yarn example start: run the example app with Expo.

Sending a pull request

Working on your first pull request? You can learn how from this free series: How to Contribute to an Open Source Project on GitHub.

When you're sending a pull request:

  • Prefer small pull requests focused on one change.
  • Verify that linters and tests are passing.
  • Review the documentation to make sure it looks good.
  • Follow the pull request template when opening a pull request.
  • For pull requests that change the API or implementation, discuss with maintainers first by opening an issue.

Publishing

Maintainers with write access to the GitHub repo and the npm organization can publish new versions. To publish a new version, first, you need to export a GH_TOKEN environment variable as mentioned here. Then run:

yarn release

This will automatically bump the version and publish the packages. It'll also publish the changelogs on GitHub for each package.

When releasing a pre-release version, we need to:

  • Update lerna.json to set the preId (e.g. alpha) and preDistTag (e.g. next) fields, and potentially the allowBranch field.
  • Run the following command:
yarn lerna publish --conventional-commits --conventional-prerelease --preid alpha

When releasing a stable version, we need to:

  • Remove the preId and preDistTag fields from lerna.json.
  • Run the following command:
yarn lerna publish --conventional-commits --conventional-graduate