Skip to content

CodeGuideline

MorganeLecurieux edited this page Jun 9, 2022 · 3 revisions

We use prettier and a linter. Please make sure your code editor is correctly configured.

General Rules

  • Format your commits with Conventional Commit (emojis are welcome though 😜)
  • Any component prop referring to an action must be prefixed by on (ex: onSubmit )

Design

Refer to Design Guidelines

Import/Export

  • Use mainly absolute imports : ~/page/Home , it will be easier to update it the file is moved

⚠️ Do not use absolute import for a sibling if there is an ``index.ts` that exports all the siblings. You'll create a circular import that might break the app

  • Except for pages , prefer named export over default exports. This will allow us to avoid mistypings in component/functions names
  • For lodash, import with the following way : import _get from 'lodash/get' - for a better tree-shaking

Make the code readable

If you need to document a lot, it's because your code isn't clear enough. Try to change variable names, cut components in smaller ones. Someone should be easily able to take over your code if needed.

Make it refacto-friendly

When you do something, try to think about refactoring that code. Use variable for any hard coded value (like route names etc...). Use enums whenever you can.

Style

To avoid dead code, all the style should be in the same file as the TS code using it. If you use the same style several time (general rule is >= 3 times but that's up to you) consider making a reusable style file.

⚠️ Inline css is forbidden in the app

Clone this wiki locally