# Code Style Rules One rule per file. Each file states a single convention in `Do this / don't do this` form, like an ESLint rule. Read every rule in this folder before writing or editing code. | Rule | Summary | | ------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------- | | [comments.md](./comments.md) | `//` single-line, `/* */` multi-line, end with a period. | | [es-modules.md](./es-modules.md) | Use `import`/`export`, not CommonJS `require`. | | [one-import-per-line.md](./one-import-per-line.md) | Only one named import per line. | | [one-class-per-file.md](./one-class-per-file.md) | One file MUST contain only one class; a route and its definition are the one exception. | | [one-component-per-file.md](./one-component-per-file.md) | One React component per file; only a tiny presentational piece may stay beside its user. | | [no-backwards-compat.md](./no-backwards-compat.md) | Refactors ignore backwards compatibility unless the prompt says otherwise. | | [no-console-in-backend.md](./no-console-in-backend.md) | No `console.*` in `api-*` code; use the DI `Logger`. | | [no-inline-class-in-create-implementation.md](./no-inline-class-in-create-implementation.md) | Declare implementation classes separately with an `implements` clause. | | [compose-css-class-names.md](./compose-css-class-names.md) | Compose class names with a `cn` helper, never `+` or template literals. | | [no-inline-conditional-spreads.md](./no-inline-conditional-spreads.md) | Build objects with `if` statements, not inline conditional spreads/casts. | | [no-nested-call-arguments.md](./no-nested-call-arguments.md) | Name each step; don't nest calls as arguments to other calls. | | [one-public-function-per-file.md](./one-public-function-per-file.md) | One exported function per file; composition steps always get their own. | | [prefer-type-annotation-over-cast.md](./prefer-type-annotation-over-cast.md) | Annotate the variable; never add parens just to cast an expression. | | [no-container-as-service-locator.md](./no-container-as-service-locator.md) | Declare dependencies; don't inject a Container and resolve inside methods. | | [use-cases-go-through-repositories.md](./use-cases-go-through-repositories.md) | Use cases depend on a repository; only it touches storage operations. | | [no-mixed-layers-in-dependencies.md](./no-mixed-layers-in-dependencies.md) | A class that composes use cases uses them for every step; write the missing one. | | [no-stateless-private-methods.md](./no-stateless-private-methods.md) | A private method that never reads `this` becomes a module-level function. | | [presenter-owns-component-state.md](./presenter-owns-component-state.md) | Non-trivial component state goes in a presenter, reached via `useFeature`. | | [services-through-di-not-react-context.md](./services-through-di-not-react-context.md) | Admin services and config are DI features reached with `useFeature`, not React context. | | [reach-abstractions-through-the-namespace.md](./reach-abstractions-through-the-namespace.md) | Use `Foo.Interface`; don't re-export the `IFoo` behind it. | | [no-multiline-ternaries.md](./no-multiline-ternaries.md) | Ternaries stay on one line; wrapping or nested ones become `if` statements. | | [routes-delegate-to-use-cases.md](./routes-delegate-to-use-cases.md) | Routes parse and map; feature logic lives in a use case. | | [prefer-provider-over-resolved-value.md](./prefer-provider-over-resolved-value.md) | Inject a provider with `get()`; never an abstraction holding another's result. | | [check-the-layer-below-before-caching.md](./check-the-layer-below-before-caching.md) | Check whether the layer below already caches; memoizing providers go per request. | | [without-authorization-only-for-private-models.md](./without-authorization-only-for-private-models.md) | `withoutAuthorization` is a no-op on private models; keep it where reads are filtered. | | [use-cases-may-share-a-repository.md](./use-cases-may-share-a-repository.md) | Call another feature's repository directly unless you need what its use case adds. | | [request-state-is-container-scoped.md](./request-state-is-container-scoped.md) | Request state registered in the root uses `inContainerScope()`, never a singleton. | When adding a new code-style rule, create a new `*.md` file here (one rule per file) and add it to the table above.