Skip to content

Latest commit

History

History
94 lines (66 loc) 路 5.55 KB

CONTRIBUTING.md

File metadata and controls

94 lines (66 loc) 路 5.55 KB

Contributing Guide

This page contains guidelines for contributing to this project. Please review these guidelines before submitting any pull requests.

This repo uses yarn workspaces, you must install yarn as the package manager.

Shared: Installation Guide

Project setup

Perform the following steps to setup the project:

  1. Fork and clone the repo.
  2. Run yarn to install dependencies.
  3. Run yarn build to build the packages for it to be available across all the packages.
  4. Create a branch for your PR with git checkout -b pr/your-branch-name.

Tip: You must keep your master branch pointing at the original repository and make pull requests from branches on your fork.

To follow the same, run:

git remote add upstream https://github.com/medly/medly-components.git
git fetch upstream
git branch --set-upstream-to=upstream/master master
  • This command adds the original repository as a remote called upstream
  • Fetch the git information from that remote and set your local 'master' branch to use the upstream master branch whenever you run 'git pull'
  • Make all your pull requests branches based on this 'master' branch
  • To update your version of 'master' perform a regular 'git pull'

Commit messages

This repo is Commitizen friendly

When comitting any file for the first time, run yarn init:commitizen as a one time configuration, so the next time when you run git commit you are asked the right set of questions about the commit.

Props naming rules

Please find in the table below the different props naming rules:

Description Suggestion Example
Initialize prop default + PropName defaultActive in Tabs component
Display related naming show + PropName showSelectAll in CheckBoxGroup component
Disable prop disabled disabled in TextField component
Current state of a component is + State isLoading in Table component
If you want to trigger an HTML supported event on + EventName onClick={(e) => void} in Button component
If you want to trigger a prop event on + PropName + EventName onInputChange={() => void} in SearchBox component
If you want to trigger a function before an event before + EventName
If you want to trigger a function after an event after + EventName

Development workflow

After setting the project, run yarn to fetch all the dependencies. Then you can run the following commands:

  • yarn clean to delete node_modules and remove all linking across packages. Once done, you must run yarn & yarn build to build the packages again.
  • yarn storybook to run storybook for local developments.
  • yarn lint to run both css and ts lint.
  • yarn watch to continuously bundle the packages. This is helpful when you have linked any package with some local project.
  • yarn build to build the packages.
  • yarn test to run tests and type check.

Unit tests

We use react-testing-library and jest to write the unit test cases. Since we try to maintain a hundred percent test coverage, ensure to add unit tests for the changes.

Please find below the test commands to help you run the tests:

  • yarn test to run tests and type check.
  • yarn test:update to update snapshots.
  • yarn test:jest to run jest with all the compatible jest CLI commands like yarn test:jest Modal --watch.
  • yarn test:watch to watch all the tests.

Some useful reference blogs:

https://kentcdodds.com/blog/common-mistakes-with-react-testing-library

https://kentcdodds.com/blog/write-tests

Pull Requests

The pull request process differs for new features and bugs. Before sending a pull request for a new feature, you should first create an issue with [Proposal] in the title. The proposal should describe the new feature, as well as implementation ideas. The proposal will then be reviewed and either approved or denied. Once a proposal is approved, a pull request may be created implementing the new feature.

Pull requests for bugs may be sent without creating any proposal issue. If you believe that you know of a solution for a bug that has been filed on GitHub, please leave a comment detailing your proposed fix.

Please fill all the information asked in the PR template.

Feature Requests

If you have an idea for a new feature you would like to see added, you may create an issue on GitHub with [Request] in the title. The feature request will then be reviewed.

Please fill all the information asked in the Feature Request template.