Skip to content

SvelteKit conventions

  • Use interface instead of type whenever possible.
  • For any component Component.svelte, define props as interface ComponentProps.
  • Use === instead of == whenever possible.
  • Prefer ?? over || unless you explicitly need to handle other falsy values.
  • Naming conventions:
    • Camel case in code most of the times.
    • Pascal case for classes, interfaces and types.
    • Camel case for HTML ids/names, but kebab case for class names.
    • Kebab case for folders in routes/.
    • Pascal case for components and component files.
    • Save non-Svelte filenames lowercase snake case.
    • Enum class property names uppercase, but string values lowercase.
    • Boolean variables and methods/functions returning boolean should be prefixed with is or has.
    • Use the same names for interfaces and properties corresponding to specific Pydantic models/schemas and attributes.
    • Interface names in singular unless inappropriate.
    • Strings and multilines using singlequotes.
    • Environment variables uppercase snake case.