Understand the @factory/constants-file-organization rule
mainThe @factory/constants-file-organization rule enforces a centralized structure for constants to improve maintainability and prevent magic values from being scattered across the codebase.
It enforces three specific constraints:
- Location: All exported constants must reside in files named
constants.ts. - Content: Files named
constants.tsare restricted toconstdeclarations only (no functions or other logic). - Imports: Imports within
constants.tsare strictly limited to:- External modules
- Media files
- Internal
enums.ts,types.ts,constants.ts, orschema.tsfiles.
Exemptions: Constants that are initialized via function calls, new expressions, or tagged templates are exempt from the location restriction (e.g., export const logger = createLogger() is allowed in non-constant files).