Skip to content

Style guidelines

Jack Branch edited this page Jan 15, 2023 · 3 revisions

Styling Conventions

Clean and consistent code is ideal. We don't necessarily different areas of the same codebase to look alien. We should strive to have consistent, readable code.

Python

Adhere to standard PEP-8 styling guidelines for Python. They are surprisingly readable.

  • Four space indent
    • More nuance on indentation can be found in the PEP-8 guidelines
  • 80 Character max length Additionally:
  • Statically type variables when possible
    • Python now supports static typing in a syntax similar to TypeScript
  • If a class is only used for data, use a more appropriate class type
    • Use a pydantic BaseModel or a dataclass
  • PascalCase for class names
  • snake_case for variables, functions, and methods

TypeScript

Our npm create sveletkit application automatically set up an npm command for us to run to format our code in the front end application. It's as simple as typing the following when in the App directory.

npm run format
npm run lint

Using prettier and eslint should result in fine TypeScript code, but the ideas are as follows:

  • 2 space indent (industry standard)
    • A good reason for this is that code nested two or three layers deep can become quite annoying to scroll and read when you're using four spaces as opposed to two.
  • PascalCase for class names (standard convention)
  • camelCase for variables, functions, and methods (standard convention)

Note

If there are any questions, comments, or concerns about this style guide, we can discuss them. This is only a first edition, but generally I think these are good standards to adhere to.