Similar to the above, we put our tests in a subdirectory called __tests__
.
Acronyms should be camel case, like this:
Naming
JSON
useSWRT => useSwrt handleGraphQLRequest => handleGraphQlRequest
For internal types (not going to be consumed), prefix with I
For amino
, we do not do this because it is a library and will be consumed
Optional Chaining
JSON
const shippingSettings = shippingSettingsData?.json;
In Typescript, we use Optional Chaining to help avoid breaking the code if the value could be nullish. When a value is returned as null
or undefined
, the ?.
operator will default to undefined
- unless another value is set as the default after the ||
operator.
Before:
Expected Property Shorthand
JSON
dispatch({ type: changeString, name: creditReasonCode, value: value, })
After:
Expected Property Shorthand
JSON
dispatch({ type: changeString, name: creditReasonCode, value, })
alt + click
on a component name to see where it is consumedsrc/pages
as const
pnpm version:patch
Tags
JSON
"scripts": { "version:patch": "pnpm version patch -m 'Bump version %s' && pnpm push:tags", "version:minor": "pnpm version minor -m 'Bump version %s' && pnpm push:tags", "version:major": "pnpm version major -m 'Bump version %s' && pnpm push :tags", "push:tags": "git push --follow-tags" }
Storybook
We use Storybook to isolate components for testing. We put all related stories for a component in a subdirectory called
__stories__
, which should be located as close as possible to the component in question.