Skip to content

Apply function style convention across API and web #66

@sam821203

Description

@sam821203

Description

Introduce and apply a consistent function style across the codebase: use arrow functions for all non-component code (helpers, API functions, handlers, mappers, hooks, async functions), and function declarations for React components and anything that returns JSX. A Cursor rule (.cursor/rules/function-style.mdc) documents the convention, and ESLint is updated to enforce it.

Proposed solution

  • Use const name = (params): ReturnType => { ... } (or export const name = ...) for non-component code; use export const name = async (...) => ... for async.
  • Use function ComponentName(props) for React components, subcomponents, and providers (e.g. pages, modals, DataBoundary, NotificationProvider).
  • Add .cursor/rules/function-style.mdc describing the convention.
  • Extend eslint.config.js to enforce the chosen styles.
  • Refactor apps/api and apps/web to follow the convention (controllers, services, repositories, DTOs, API client, hooks, components, mocks).

Acceptance criteria

  • Function style rule is documented in .cursor/rules/function-style.mdc.
  • ESLint config enforces arrow functions for non-components and function declarations for React components.
  • All API code (NestJS controllers, services, repositories, guards, interceptors, filters, config, mappers, DTOs) uses the arrow-function style where applicable.
  • All web code (API client, error handler, hooks, helpers, mocks) uses arrow functions; React components use function declarations.
  • Explicit return types and type annotations are preserved where they existed.
  • Existing behavior is unchanged; refactor is style-only.

Additional context

Branch: refactor/function-style

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions