Skip to content

Latest commit

 

History

History
136 lines (89 loc) · 4.02 KB

CONTRIBUTING.md

File metadata and controls

136 lines (89 loc) · 4.02 KB

Contributing

This repository is created by using Turborepo. To understand the repository structure better, please check its documentation.

Local Development

After cloning the repository, we need to install the dependencies.

npm install

To start the demo Next.js app which uses the local version of react-intersection-obverser-hook, we can run dev script.

npm run dev

After this, we can open http://localhost:3000 in the browser to display the app.

Code Quality Checks

We use automated checks by using ESLint, Prettier and TypeScript to provide the highest quality code as it can be.

All checks are run automatically before committing by using husky and lint-staged.

The checks can be run manually by running the below command too.

npm run codequality:check

And the same checks can be run also by enabling fixes for auto-fixable issues.

npm run codequality:fix

codequality scripts run underlying ESLint (lint), Prettier (format) and TypeScript (types) scripts. To run these tools individually, we can also use the below scripts.

# ESLint checks
npm run lint:check
# ESLint fixes
npm run lint:fix

# Prettier checks
npm run format:check
# Prettier fixes
npm run format:fix

# TypeScript checks
npm run types:check
# There is no auto-fix script for TypeScript.

Updating Dependencies

We use npm-check-updates package to automatically check if there are newer versions of our dependencies.

To run it, we can use the below command. It starts an interactive CLI to check the dependencies of all the apps and packages, including the root dependencies.

npm run updates:check

Adding Contributors

all-contributors-cli is used for maintaining the contributors of this repository.

To add a new contributor, we can run the below command and follow its instructions.

npm run contributors:add

Prepublish Checks

To be sure everything is OK with the latest changes, we can use publint and Are the Types Wrong.

Firstly, we need to build the bundle with the latest changes.

npm run build:bundle

This command will create (or update) the packages/react-intersection-observer-hook/dist folder, which will be used by the clients of this package.

To be sure the output is OK for ESM and CJS clients, we can run the below commands and check their outputs.

# For `publint`
npm run publint:check -w react-intersection-observer-hook

# For `Are the Types Wrong`
npm run attw:check -w react-intersection-observer-hook

To see the content of the package which can be uploaded to npm can be seen by using the below command. It will create a tarball from react-intersection-observer-hook package.

npm pack -w react-intersection-observer-hook

Or the below command can be used to only check the tarball contents without creating it.

npm pack --dry-run -w react-intersection-observer-hook

Lastly, we can run the below command to auto correct common errors in package.json of the package to be published. npm publish command already does these auto-fixes too.

npm pkg fix -w react-intersection-observer-hook

Publishing the Package

Firstly, we need to bump the package version which can be done by using the below commands.

npm version patch -w react-intersection-observer-hook
# Bumps the patch number like 0.0.0 -> 0.0.1

npm version minor -w react-intersection-observer-hook
# Bumps the patch number like 0.0.x -> 0.1.0

npm version major -w react-intersection-observer-hook
# Bumps the patch number like 0.x.y -> 1.0.0

And we can publish the new version now 🚀

npm publish -w react-intersection-observer-hook