This guide was heavily based on https://github.com/react-hookz/web/blob/master/CONTRIBUTING.md. Pure 💖 awesomeness 💖.
Thanks for contributing to @mirohq/websdk-react-hooks
.
If you are contributing for the first time, we recommend reading this First Contributions guide first.
- Fork the main repo
- Clone the repo to your computer (add
--depth=1
togit clone
command to save time) - Install dependencies:
yarn
- Make sure everything builds and tests:
yarn build && yarn test
- Create a branch for your PR:
git checkout -b my-awesome-hook
- if you are adding a new hook, name the branch based on the hook:
useUpdateEffect
- if your change fixes an issue, name the branch based on the issue number:
fix-12345
- if you are adding a new hook, name the branch based on the hook:
- Follow the directions below:
Tip: to keep your
main
branch pointing to the original repo'smain
(instead of your fork'smain
) do this:git remote add upstream https://github.com/miroapp/miro-react-hooks git fetch upstream git branch --set-upstream-to=upstream/main mainAfter running these commands you'll be able to easily pull changes from the original repository with
git pull
.
- Implement the hook in the
src
folder.- The folder should be named after your new hook, for instance:
./src/myAwesomeHook
. - The file with hook implementation should use the same name and be placed inside the above created subdirectory as
./src/myAwesomeHook/myAwesomeHook.ts
- The hook should be exported by name, not default-exported.
- If the hook has custom types in its parameters or return values, they should be exported as well.
- Types and interfaces should not have prefixes like
I
orT
. - The hook should be developed to run specifically in the client.
- If your hook reuses other
@mirohq/websdk-react-hooks
hooks, import them asimport { useMiro } from '../useMiro';
instead ofimport { useMiro } from '..';
- Create an
index.ts
file within the same subdirectory and export all the hook dependencies.
- The folder should be named after your new hook, for instance:
- Re-export the hook implementation and all its custom types in
./src/index.ts
. - Fully test your hook, the test filename should use the same hook's name,
./src/myAwesomeHook/myAwesomeHook.text.tsx
- Write docs for your hook.
- Docs should be colocated with the implementation using the same name for the markdown file, following our previous example, it should be
./src/myAwesomeHook/myAwesomeHook.md
. - Write a short example demonstrating your hook in that markdown file.
- Docs should be colocated with the implementation using the same name for the markdown file, following our previous example, it should be
- Add a summary of the hook and a link to the docs to
README.md
. - After all the above steps are done, run
yarn format
to ensure that everything is styled by our standards and there are no linting issues. yarn new-hook myAwesomeHook
will help you to create a proper file structure for the new hook.
This repo uses commit-and-tag-version and
conventional commit messages so prefix your commits with fix:
,
feat:
, etc., so that your changes appear in the
release notes.
Also, there is a script that helps you to properly format commit messages:
git add .
yarn commit
The script guides you through several prompts that help you with writing a good commit message, including many non-obvious and easy-to-forget parts.
This project includes Git hooks that are automatically enabled when you install the dependencies. These hooks automatically test and validate your code and commit messages before each commit. In most cases disabling these hooks is not recommended.