- Images to be put in
./src/assets/images
and css in./src/assets/css
.
- Imports
- Reusable components needed for the main component
- Main component (Eg: Addons in addons.js)
export default MainComponent;
- Use
mylog
function instead of console.log!
- Do not make a new file for smaller components.
- Smaller, reusable components needed in the main components should be added above the main component, not inside it.
-
CSS:
- Use as little custom css as possible.
- Use bootstrap classnames instead of creating your own.
- Make sure your classnames are unique and dont affect any other part of app.
- Take primary/secondary/muted etc color from bootstrap instead of putting their values manually.
/* bad */ .myclass { color: #bcbcbc; } /* good */ .myclass { color: var(--muted); }
-
Images:
Put images in the
src/assets/images/<module>
folder and add it inutils/getIcons
and use from there. -
New Components:
Put new components in
src/components/<module>/<component>.js
file. -
New Pages:
Put new pages in
src/pages/<page>.js
file. If the page is at a sub path eg./group/scrum
it should be insrc/pages/group/Scrum.js
.The structure of
src/pages
folder should mimic the routes available. -
JS:
- Use a space after
if
,for
,while
,switch
. - Do not use a space after the opening
(
and before the closing)
. - Use a space before and after destructuring objects.
//good const { apple, mangoes } = fruits; //bad const { apple, mangoes } = fruits; //Same for destructuring props: //good const BeautifulComponent = ({ prop1, prop2 }) => {}; //bad const UglyComponent = ({ prop1, prop2 }) => {};
- Use a space after
-
JSX:
- Use a space before the forward slash (
/
) of a self-closing tag
//good <Foo /> //bad <Foo/>
- Do not use spaces for JSX curly braces
//good <Foo bar={baz} /> //bad <Foo bar={ baz } />
- Use a space before the forward slash (
-
Use camelCase for prop names, or PascalCase if the prop value is a React component.
-
Use new lines when props do not fit on the same line.
//good <Foo prop1={value1} prop2={value2} prop3={value3} /> //bad <Foo prop1={value1} prop2={value2} prop3={value3} />