1.2.0 • Published 2 years ago
@thewave-studio/code-library v1.2.0
The Wave - Code library
This library contains reusable pieces of code created by The Wave Studio, that can be used across multiple projects
HOW TO USE IT
- Create a
.npmrcfile at the root of your project with this snippet of code
//registry.npmjs.org/:_authToken=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- Install the library as usual using
npm i @thewave-studio/code-libraryoryarn add @thewave-studio/code-library - Use the library as usual, for example
import {useMousePosition} from "@thewave-studio/code-library"HOW TO CONTRIBUTE TO THE LIBRARY
- Install the modules by running
npm ioryarnand then runnpm prepareoryarn run prepareto install Husky hooks - The
mainbranch is used to ship production ready code - DO NOT RUN
git committo do the commit. Runyarn run commitornpm run commitinstead. Conventional Commits MUST BE USED to ensure thatsemantic releasecan identify the type of commit and increase the package version accordingly. Read more about it here.
REACT HOOKS
REGEX
- VALID_URL_REGEX This regex validates an URL and it can also be used to determine whether an URL is external which can be useful when using routing in SPA
- ITALIAN_PHONE_NUMBER_REGEX This regex validates an italian phone number (with prefix +39)
UTILITY
yarn new-hook nameOfTheHookornpm run new-hook nameOfTheHook(wherenameOfTheHookis the hook name): this utility will help you create a folder structure and the necessary files to create a new hook (test, hook, markdown and demo). Keep in mind that this will create just some boilerplate files but with a consistent structure.